Skip to main content

BlockBuilder

Struct BlockBuilder 

Source
pub struct BlockBuilder<T: Copy, const N: usize> { /* private fields */ }
Expand description

Privately fills one block and publishes it to the caller only when complete.

A discontinuous sample is rejected without changing the partial block. The caller can preserve it, or call clear and retry the returned sample as the start of a new window. This keeps loss policy explicit.

Implementations§

Source§

impl<T: Copy, const N: usize> BlockBuilder<T, N>

Source

pub const fn new() -> Self

Create an empty builder.

N == 0 is rejected at compile time.

Source

pub fn push( &mut self, sequence: u32, sample: T, ) -> Result<Option<Block<T, N>>, FillError<T>>

Append one sequenced sample.

Returns Ok(None) while the block is partial and Ok(Some(block)) exactly when the Nth sample completes it. Completion also resets the builder, ready for the next block.

Source

pub fn clear(&mut self)

Discard the partial block, if any.

Source

pub const fn len(&self) -> usize

Number of samples currently held in the private partial block.

Source

pub const fn is_empty(&self) -> bool

Whether no partial block is being filled.

Source

pub const fn capacity(&self) -> usize

Number of samples required for a complete block.

Source

pub const fn expected_sequence(&self) -> Option<u32>

Sequence required by the next push, or None when any non-zero sequence may start a new block.

Trait Implementations§

Source§

impl<T: Copy, const N: usize> Debug for BlockBuilder<T, N>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Copy, const N: usize> Default for BlockBuilder<T, N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for BlockBuilder<T, N>
where T: Freeze,

§

impl<T, const N: usize> RefUnwindSafe for BlockBuilder<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> Send for BlockBuilder<T, N>
where T: Send,

§

impl<T, const N: usize> Sync for BlockBuilder<T, N>
where T: Sync,

§

impl<T, const N: usize> Unpin for BlockBuilder<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnsafeUnpin for BlockBuilder<T, N>
where T: UnsafeUnpin,

§

impl<T, const N: usize> UnwindSafe for BlockBuilder<T, N>
where T: UnwindSafe,

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.