Skip to main content

SendBatchRaw

Struct SendBatchRaw 

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

A raw send batch with dynamic capacity.

This is the underlying type behind SendBatch<N>. It manages a dynamically-allocated slot array. The typed SendBatch<N> wrapper provides a compile-time capacity via std::ops::DerefMut to this type.

Most users should use SendBatch<N> instead.

Implementations§

Source§

impl SendBatchRaw

Source

pub fn with_capacity(capacity: usize) -> Self

Creates a new raw send batch with the given capacity.

The internal slot vector is pre-allocated to capacity elements.

Source

pub fn push( &mut self, data: &[u8], addr: Option<SocketAddr>, ) -> Result<(), BingerError>

Pushes a buffer and optional destination address into the raw send batch.

When addr is None, the packet will be sent on a connected socket (equivalent to SendBatch::push_connected). When addr is Some(...), the packet is sent to that specific address (connectionless mode).

§Errors

Returns BingerError::BatchFull if the batch has reached its capacity.

Source

pub fn len(&self) -> usize

Returns the number of packets currently in the batch.

Source

pub fn is_empty(&self) -> bool

Returns true if the batch contains no packets.

Source

pub fn entry(&self, idx: usize) -> (&[u8], Option<SocketAddr>)

Returns the data and optional destination address at index idx.

§Panics

Panics if idx is out of bounds.

Source

pub fn clear(&mut self)

Removes all packets from the batch, resetting it for reuse.

No memory is deallocated.

Auto Trait Implementations§

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.