Skip to main content

DataPlaneIo

Trait DataPlaneIo 

Source
pub trait DataPlaneIo {
    // Required methods
    fn backend(&self) -> Backend;
    fn send(&mut self, datagram: &[u8]) -> Result<()>;
    fn recv(&mut self, buf: &mut [u8]) -> Result<usize>;

    // Provided methods
    fn send_batch(&mut self, datagrams: &[&[u8]]) -> Result<usize> { ... }
    fn recv_batch(
        &mut self,
        bufs: &mut [[u8; 2048]],
        lens: &mut [usize],
    ) -> Result<usize> { ... }
}
Expand description

Sends and receives wire datagrams via the selected backend. Implemented in M4.

Required Methods§

Source

fn backend(&self) -> Backend

The backend actually selected at startup (after probing/fallback).

Source

fn send(&mut self, datagram: &[u8]) -> Result<()>

Send one datagram.

Source

fn recv(&mut self, buf: &mut [u8]) -> Result<usize>

Receive one datagram into buf, returning its length.

Provided Methods§

Source

fn send_batch(&mut self, datagrams: &[&[u8]]) -> Result<usize>

Send up to datagrams.len() datagrams in one syscall where supported.

Returns the number of datagrams actually sent. The default implementation loops over DataPlaneIo::send; override for real batching (e.g. sendmmsg).

Source

fn recv_batch( &mut self, bufs: &mut [[u8; 2048]], lens: &mut [usize], ) -> Result<usize>

Receive up to bufs.len() datagrams in one syscall where supported.

Fills lens[i] with the byte count of the i-th received datagram and returns the number of datagrams received. The default implementation does a single DataPlaneIo::recv; override for real batching (e.g. recvmmsg).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§