Trait smoltcp::phy::Device

source ·
pub trait Device {
    type RxToken<'a>: RxToken
where Self: 'a; type TxToken<'a>: TxToken
where Self: 'a; // Required methods fn receive(
&mut self,
timestamp: Instant
) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)>; fn transmit(&mut self, timestamp: Instant) -> 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§

source

type RxToken<'a>: RxToken
where
Self: 'a

source

type TxToken<'a>: TxToken
where
Self: 'a

Required Methods§

source

fn receive(
&mut self,
timestamp: Instant
) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)>

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.

The timestamp must be a number of milliseconds, monotonically increasing since an arbitrary moment in time, such as system startup.

source

fn transmit(&mut self, timestamp: Instant) -> Option<Self::TxToken<'_>>

Construct a transmit token.

The timestamp must be a number of milliseconds, monotonically increasing since an arbitrary moment in time, such as system startup.

source

fn capabilities(&self) -> DeviceCapabilities

Get a description of device capabilities.

Implementors§

source§

impl Device for Loopback

§

type RxToken<'a> = RxToken

§

type TxToken<'a> = TxToken<'a>

source§

impl Device for RawSocket

§

type RxToken<'a>
where
Self: 'a
= RxToken

§

type TxToken<'a>
where
Self: 'a
= TxToken

source§

impl Device for TunTapInterface

§

type RxToken<'a> = RxToken

§

type TxToken<'a> = TxToken

source§

impl<D: Device> Device for FaultInjector<D>

§

type RxToken<'a>
where
Self: 'a
= RxToken<'a>

§

type TxToken<'a>
where
Self: 'a
= TxToken<'a, <D as Device>::TxToken<'a>>

source§

impl<D: Device> Device for Tracer<D>

§

type RxToken<'a>
where
Self: 'a
= RxToken<<D as Device>::RxToken<'a>>

§

type TxToken<'a>
where
Self: 'a
= TxToken<<D as Device>::TxToken<'a>>

source§

impl<D: Device, FTx, FRx> Device for FuzzInjector<D, FTx, FRx>where
FTx: Fuzzer,
FRx: Fuzzer,

§

type RxToken<'a>
where
Self: 'a
= RxToken<'a, <D as Device>::RxToken<'a>, FRx>

§

type TxToken<'a>
where
Self: 'a
= TxToken<'a, <D as Device>::TxToken<'a>, FTx>

source§

impl<D: Device, S> Device for PcapWriter<D, S>where
S: PcapSink,

§

type RxToken<'a>
where
Self: 'a
= RxToken<'a, <D as Device>::RxToken<'a>, S>

§

type TxToken<'a>
where
Self: 'a
= TxToken<'a, <D as Device>::TxToken<'a>, S>