Skip to main content

Interleaver

Struct Interleaver 

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

Buffers up to depth blocks of datagrams and emits them column-major so each block’s shards are spaced depth apart on the wire.

Implementations§

Source§

impl Interleaver

Source

pub fn new(depth: usize) -> Self

Create an interleaver of the given depth (clamped to at least 1).

Source

pub fn depth(&self) -> usize

Current interleave depth.

Source

pub fn set_depth(&mut self, depth: usize) -> Vec<Vec<u8>>

Change the interleave depth. Any buffered blocks are flushed first (returned to the caller) so the depth change does not reorder a partially-staged group.

Source

pub fn buffered_blocks(&self) -> usize

Number of blocks currently buffered.

Source

pub fn add_block(&mut self, datagrams: Vec<Vec<u8>>) -> Vec<Vec<u8>>

Stage one block’s datagrams. Returns the interleaved datagrams ready to transmit: empty until depth blocks are buffered, then the whole interleaved group. At depth 1 the block is returned immediately (pass-through, no added latency).

Source

pub fn flush(&mut self) -> Vec<Vec<u8>>

Emit whatever blocks are buffered (a short final group), interleaved. Empty if nothing is staged.

Trait Implementations§

Source§

impl Debug for Interleaver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.