[][src]Trait ethox::nic::Device

pub trait Device {
    type Handle: Handle + ?Sized;
    type Payload: Payload + ?Sized;
    fn personality(&self) -> Personality;
fn tx(
        &mut self,
        max: usize,
        sender: impl Send<Self::Handle, Self::Payload>
    ) -> Result<usize>;
fn rx(
        &mut self,
        max: usize,
        receiver: impl Recv<Self::Handle, Self::Payload>
    ) -> Result<usize>; }

A layer 2 device.

Associated Types

type Handle: Handle + ?Sized

The control handle type also providing packet meta information.

type Payload: Payload + ?Sized

The payload buffer type of this device.

It can be an owning buffer such as Vec<u8> or a non-owning buffer or even only emulate a buffer containing an Ethernet packet. Note that the buffer trait should stay a type parameter so that upper layers can make use of additional methods and not be constrained to the Payload trait. (Although smart use of Any might in some cases suffice in a real, specific network stack that is not this library).

Loading content...

Required methods

fn personality(&self) -> Personality

A description of the device.

Could be dynamically configured but the optimizer and the user is likely happier if the implementation does not take advantage of this fact.

fn tx(
    &mut self,
    max: usize,
    sender: impl Send<Self::Handle, Self::Payload>
) -> Result<usize>

Transmit some packets utilizing the sender.

Up to max packet buffers are chosen by the device. They are provided to the sender callback which may initialize their contents and decide to queue them. Afterwards, the device is responsible for cleaning up unused buffers and physically sending queued buffers.

fn rx(
    &mut self,
    max: usize,
    receiver: impl Recv<Self::Handle, Self::Payload>
) -> Result<usize>

Receive packet utilizing the receptor.

Dequeue up to max received packets and provide them to the receiver callback.

Loading content...

Implementors

impl<'_, D> Device for Lossy<'_, D> where
    D: Device
[src]

type Handle = LossyHandle<D::Handle>

type Payload = D::Payload

impl<'a, C: PayloadMut> Device for Loopback<'a, C>[src]

type Handle = Handle

type Payload = C

impl<T, P> Device for External<T> where
    T: Deref<Target = [P]> + DerefMut,
    P: Payload
[src]

type Handle = Handle

type Payload = P

Loading content...