Batch

Struct Batch 

Source
pub struct Batch { /* private fields */ }
Expand description

Holds multiple packet descriptors to avoid unnecessary allocations on each Interface::read_batch() and Interface::write_batch() calls.

Implementations§

Source§

impl Batch

Source

pub fn preallocate(count: usize) -> Batch

Preallocates a batch of size count which holds the packet descriptors.

These packet descriptors are used internally by Interface::read_batch() and Interface::write_batch().

Note that you’ll only be able to receive or send as many packets as preallocated in a batch.

Source

pub fn packet_sizes(&self) -> impl Iterator<Item = usize> + use<'_>

Retrieves packet sizes received after calling the Interface::read_batch().

Note that since a Batch abstraction lacks any information about the number of packets received, use Iterator::take() on the returned iterator in order to limit it to only useful items.

Source

pub fn packet_sized_bufs<'a, B>( &self, bufs: &'a [B], ) -> impl Iterator<Item = &'a [u8]> + use<'a, '_, B>
where B: AsRef<[u8]>,

Given a slice of buffers used for a call to Interface::read_batch(), returns an iterator over mutable slices derived from the provided buffers, where each slice is limited to the corresponding received packet length.

This method is based on Batch::packet_sizes() and is provided for convenience.

Note that since a Batch abstraction lacks any information about the number of packets received, use Iterator::take() on the returned iterator in order to limit it to only useful items.

Auto Trait Implementations§

§

impl Freeze for Batch

§

impl RefUnwindSafe for Batch

§

impl !Send for Batch

§

impl !Sync for Batch

§

impl Unpin for Batch

§

impl UnwindSafe for Batch

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.