pub trait NetworkDriver {
// Required methods
fn mac_address(&self) -> MacAddress;
fn can_transmit(&self) -> bool;
fn can_receive(&self) -> bool;
fn transmit(&mut self, frame: &[u8]) -> Result<(), TxError>;
fn receive(&mut self, buffer: &mut [u8]) -> Result<Option<usize>, RxError>;
fn refill_rx_queue(&mut self);
fn collect_tx_completions(&mut self);
// Provided method
fn link_up(&self) -> bool { ... }
}Expand description
Core network device interface.
All NIC drivers must implement this trait. Higher layers (smoltcp adapter, state machines) use this interface.
Required Methods§
Sourcefn mac_address(&self) -> MacAddress
fn mac_address(&self) -> MacAddress
Get MAC address.
Sourcefn can_transmit(&self) -> bool
fn can_transmit(&self) -> bool
Check if device can accept a TX frame.
Returns true if transmit() will succeed.
Sourcefn can_receive(&self) -> bool
fn can_receive(&self) -> bool
Check if device has a received frame ready.
Returns true if receive() will return Ok(Some(_)).
Sourcefn refill_rx_queue(&mut self)
fn refill_rx_queue(&mut self)
Refill RX queue with available buffers.
Called in main loop Phase 1.
Sourcefn collect_tx_completions(&mut self)
fn collect_tx_completions(&mut self)
Collect TX completions.
Called in main loop Phase 5.