Allow access to phy-device in ethernet
Adds accessor functions to the device implementing the phy::Device trait within an ethernet interface. The intent is to allow access to read-only methods such as gathering of device statistics or other diagnostics while the interface is running. The interface does not hold any internal invariants on the device, so that a mutable accessor can be added as well. Closes: #289 Approved by: whitequark
This commit is contained in:
parent
b27cbad6f4
commit
8c3bdf907b
|
@ -353,6 +353,22 @@ impl<'b, 'c, 'e, DeviceT> Interface<'b, 'c, 'e, DeviceT>
|
|||
InterfaceInner::check_ethernet_addr(&self.inner.ethernet_addr);
|
||||
}
|
||||
|
||||
/// Get a reference to the inner device.
|
||||
pub fn device(&self) -> &DeviceT {
|
||||
&self.device
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the inner device.
|
||||
///
|
||||
/// There are no invariants imposed on the device by the interface itself. Furthermore the
|
||||
/// trait implementations, required for references of all lifetimes, guarantees that the
|
||||
/// mutable reference can not invalidate the device as such. For some devices, such access may
|
||||
/// still allow modifications with adverse effects on the usability as a `phy` device. You
|
||||
/// should not use them this way.
|
||||
pub fn device_mut(&mut self) -> &mut DeviceT {
|
||||
&mut self.device
|
||||
}
|
||||
|
||||
/// Add an address to a list of subscribed multicast IP addresses.
|
||||
///
|
||||
/// Returns `Ok(announce_sent)` if the address was added successfully, where `annouce_sent`
|
||||
|
|
Loading…
Reference in New Issue