Trait smoltcp::phy::Device

source ·
pub trait Device<'a> {
    type RxToken: RxToken + 'a;
    type TxToken: TxToken + 'a;

    fn receive(&'a mut self) -> Option<(Self::RxToken, Self::TxToken)>;
    fn transmit(&'a mut self) -> Option<Self::TxToken>;
    fn capabilities(&self) -> DeviceCapabilities;
}
Expand description

An interface for sending and receiving raw network frames.

The interface is based on tokens, which are types that allow to receive/transmit a single packet. The receive and transmit functions only construct such tokens, the real sending/receiving operation are performed when the tokens are consumed.

Required Associated Types§

Required Methods§

Construct a token pair consisting of one receive token and one transmit token.

The additional transmit token makes it possible to generate a reply packet based on the contents of the received packet. For example, this makes it possible to handle arbitrarily large ICMP echo (“ping”) requests, where the all received bytes need to be sent back, without heap allocation.

Construct a transmit token.

Get a description of device capabilities.

Implementors§