pub trait NetworkDevice: Send {
// Required methods
fn name(&self) -> &str;
fn mac_address(&self) -> MacAddress;
fn capabilities(&self) -> DeviceCapabilities;
fn state(&self) -> DeviceState;
fn set_state(&mut self, state: DeviceState) -> Result<(), KernelError>;
fn statistics(&self) -> DeviceStatistics;
fn transmit(&mut self, packet: &Packet) -> Result<(), KernelError>;
fn receive(&mut self) -> Result<Option<Packet>, KernelError>;
// Provided method
fn mtu(&self) -> usize { ... }
}Expand description
Network device trait
Required Methods§
Sourcefn mac_address(&self) -> MacAddress
fn mac_address(&self) -> MacAddress
Get device MAC address
Sourcefn capabilities(&self) -> DeviceCapabilities
fn capabilities(&self) -> DeviceCapabilities
Get device capabilities
Sourcefn state(&self) -> DeviceState
fn state(&self) -> DeviceState
Get device state
Sourcefn set_state(&mut self, state: DeviceState) -> Result<(), KernelError>
fn set_state(&mut self, state: DeviceState) -> Result<(), KernelError>
Set device state
Sourcefn statistics(&self) -> DeviceStatistics
fn statistics(&self) -> DeviceStatistics
Get device statistics
Sourcefn transmit(&mut self, packet: &Packet) -> Result<(), KernelError>
fn transmit(&mut self, packet: &Packet) -> Result<(), KernelError>
Transmit a packet
Sourcefn receive(&mut self) -> Result<Option<Packet>, KernelError>
fn receive(&mut self) -> Result<Option<Packet>, KernelError>
Receive a packet (non-blocking)