Trait smoltcp::phy::Device
[−]
[src]
pub trait Device { type RxBuffer: AsRef<[u8]>; type TxBuffer: AsRef<[u8]> + AsMut<[u8]>; fn limits(&self) -> DeviceLimits; fn receive(&mut self, timestamp: u64) -> Result<Self::RxBuffer>; fn transmit(
&mut self,
timestamp: u64,
length: usize
) -> Result<Self::TxBuffer>; }
An interface for sending and receiving raw network frames.
It is expected that a Device
implementation would allocate memory for both sending
and receiving packets from memory pools; hence, the stack borrows the buffer for a packet
that it is about to receive, as well for a packet that it is about to send, from the device.
Associated Types
Required Methods
fn limits(&self) -> DeviceLimits
Get a description of device limitations.
fn receive(&mut self, timestamp: u64) -> Result<Self::RxBuffer>
Receive a frame.
It is expected that a receive
implementation, once a packet is written to memory
through DMA, would gain ownership of the underlying buffer, provide it for parsing,
and return it to the network device once it is dropped.
fn transmit(&mut self, timestamp: u64, length: usize) -> Result<Self::TxBuffer>
Transmit a frame.
It is expected that a transmit
implementation would gain ownership of a buffer with
the requested length, provide it for emission, and schedule it to be read from
memory by the network device once it is dropped.
Implementors
impl<D: Device, P: PrettyPrint> Device for Tracer<D, P> type RxBuffer = D::RxBuffer; type TxBuffer = TxBuffer<D::TxBuffer, P>;
impl<D: Device> Device for FaultInjector<D> where
D::RxBuffer: AsMut<[u8]>, type RxBuffer = D::RxBuffer; type TxBuffer = TxBuffer<D::TxBuffer>;impl<D: Device, S: PcapSink + Clone> Device for PcapWriter<D, S> type RxBuffer = D::RxBuffer; type TxBuffer = TxBuffer<D::TxBuffer, S>;
impl Device for Loopback type RxBuffer = Vec<u8>; type TxBuffer = TxBuffer;
impl Device for RawSocket type RxBuffer = Vec<u8>; type TxBuffer = TxBuffer;
impl Device for TapInterface type RxBuffer = Vec<u8>; type TxBuffer = TxBuffer;