Skip to main content

DatagramSocketBatchExt

Trait DatagramSocketBatchExt 

Source
pub trait DatagramSocketBatchExt: DatagramSocket {
    // Provided methods
    fn poll_fill_recv_batch<const SLOT_BYTES: usize, const INITIAL_CAP: usize>(
        &mut self,
        cx: &mut Context<'_>,
        slab: &mut RecvSlab<SLOT_BYTES, INITIAL_CAP>,
    ) -> Poll<Result<usize>> { ... }
    fn drain_recv_to_empty<const SLOT_BYTES: usize, const INITIAL_CAP: usize>(
        &mut self,
        slab: &mut RecvSlab<SLOT_BYTES, INITIAL_CAP>,
    ) -> usize { ... }
    fn poll_drive_send_batch<const SEND_BYTES: usize, const SPAN_CAP: usize>(
        &mut self,
        cx: &mut Context<'_>,
        batch: &SendBatch<SEND_BYTES, SPAN_CAP>,
        span_offset: &mut usize,
    ) -> Poll<Result<()>> { ... }
}
Expand description

Fills and drains RecvSlab/SendBatch over any DatagramSocket.

Provided Methods§

Source

fn poll_fill_recv_batch<const SLOT_BYTES: usize, const INITIAL_CAP: usize>( &mut self, cx: &mut Context<'_>, slab: &mut RecvSlab<SLOT_BYTES, INITIAL_CAP>, ) -> Poll<Result<usize>>

Receive one batch into slab, registering the caller’s waker. This is the AWAITED path (raced against a timer in the serve loop): on an empty socket it returns Pending with the real waker installed so the task parks. Returns the count of newly filled slots.

Zero heap: the &mut [u8] iovec array and the (len, peer) scratch are stack ArrayVec/array of width RECV_BATCH.

Source

fn drain_recv_to_empty<const SLOT_BYTES: usize, const INITIAL_CAP: usize>( &mut self, slab: &mut RecvSlab<SLOT_BYTES, INITIAL_CAP>, ) -> usize

Drain the socket to empty into slab (non-blocking, noop waker), after an initial awaited poll_fill_recv_batch. Returns the additional slots drained. Decouples drain-rate from process-rate so the default kernel datagram buffer never overflows during a handshake burst (no dependence on a raised rmem_max).

The noop waker is harmless: the real waker is reinstalled by the next iteration’s awaited poll_fill_recv_batch.

Source

fn poll_drive_send_batch<const SEND_BYTES: usize, const SPAN_CAP: usize>( &mut self, cx: &mut Context<'_>, batch: &SendBatch<SEND_BYTES, SPAN_CAP>, span_offset: &mut usize, ) -> Poll<Result<()>>

Ship staged packets from batch, resuming at span_offset. Returns Ready(Ok(())) once span_offset reaches the staged count or the send buffer fills (partial progress recorded in span_offset); the caller loops until span_offset == batch.len().

Zero heap: each sendmmsg chunk is a stack ArrayVec of width SEND_CHUNK.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§