BaseEncoder

Struct BaseEncoder 

Source
pub struct BaseEncoder<'a, T: Types> { /* private fields */ }
Expand description

An encoder capable of emitting fountain-encoded transmissions.

§Examples

See the crate::fountain module documentation for an example.

Implementations§

Source§

impl<'a> BaseEncoder<'a, Alloc>

Source

pub const fn new() -> Self

Construct a new Encoder.

Source§

impl<'a, const MAX_FRAGMENT_LEN: usize, const MAX_SEQUENCE_COUNT: usize> BaseEncoder<'a, Heapless<MAX_FRAGMENT_LEN, MAX_SEQUENCE_COUNT>>

Source

pub const fn new() -> Self

Constructs a new HeaplessEncoder.

Source§

impl<'a, T: Types> BaseEncoder<'a, T>

Source

pub fn start(&mut self, message: &'a [u8], max_fragment_length: usize)

Start encoding a new message.

§Panics

This function panics if:

  • The message is empty.
  • The maximum fragment length is zero.
  • The maximum fragment length is large than what T::Data can hold.
Source

pub fn current_sequence(&self) -> u32

Returns the current count of how many parts have been emitted.

Source

pub fn sequence_count(&self) -> u32

Returns the number of segments the original message has been split up into.

Source

pub fn is_complete(&self) -> bool

Returns whether all original segments have been emitted at least once. The fountain encoding is defined as doing this before combining segments with each other. Thus, this is equivalent to checking whether current_sequence >= fragment_count.

Source

pub fn next_part(&mut self) -> Part<'_>

Returns the next part to be emitted by the fountain encoder. After all parts of the original message have been emitted once, the fountain encoder will emit the result of xor-ing together the parts selected by the Xoshiro RNG (which could be a single part).

§Examples

See the crate::fountain module documentation for an example.

Auto Trait Implementations§

§

impl<'a, T> Freeze for BaseEncoder<'a, T>
where <T as Types>::Data: Freeze, <T as Types>::Indexes: Freeze, <<T as Types>::Chooser as Types>::Indexes: Freeze, <<T as Types>::Chooser as Types>::Shuffled: Freeze, <<<T as Types>::Chooser as Types>::Sampler as Types>::Aliases: Freeze, <<<T as Types>::Chooser as Types>::Sampler as Types>::Probs: Freeze, <<<T as Types>::Chooser as Types>::Sampler as Types>::Weights: Freeze, <<<T as Types>::Chooser as Types>::Sampler as Types>::S: Freeze, <<<T as Types>::Chooser as Types>::Sampler as Types>::L: Freeze,

§

impl<'a, T> RefUnwindSafe for BaseEncoder<'a, T>

§

impl<'a, T> Send for BaseEncoder<'a, T>
where <T as Types>::Data: Send, <T as Types>::Indexes: Send, <<T as Types>::Chooser as Types>::Indexes: Send, <<T as Types>::Chooser as Types>::Shuffled: Send, <<<T as Types>::Chooser as Types>::Sampler as Types>::Aliases: Send, <<<T as Types>::Chooser as Types>::Sampler as Types>::Probs: Send, <<<T as Types>::Chooser as Types>::Sampler as Types>::Weights: Send, <<<T as Types>::Chooser as Types>::Sampler as Types>::S: Send, <<<T as Types>::Chooser as Types>::Sampler as Types>::L: Send,

§

impl<'a, T> Sync for BaseEncoder<'a, T>
where <T as Types>::Data: Sync, <T as Types>::Indexes: Sync, <<T as Types>::Chooser as Types>::Indexes: Sync, <<T as Types>::Chooser as Types>::Shuffled: Sync, <<<T as Types>::Chooser as Types>::Sampler as Types>::Aliases: Sync, <<<T as Types>::Chooser as Types>::Sampler as Types>::Probs: Sync, <<<T as Types>::Chooser as Types>::Sampler as Types>::Weights: Sync, <<<T as Types>::Chooser as Types>::Sampler as Types>::S: Sync, <<<T as Types>::Chooser as Types>::Sampler as Types>::L: Sync,

§

impl<'a, T> Unpin for BaseEncoder<'a, T>
where <T as Types>::Data: Unpin, <T as Types>::Indexes: Unpin, <<T as Types>::Chooser as Types>::Indexes: Unpin, <<T as Types>::Chooser as Types>::Shuffled: Unpin, <<<T as Types>::Chooser as Types>::Sampler as Types>::Aliases: Unpin, <<<T as Types>::Chooser as Types>::Sampler as Types>::Probs: Unpin, <<<T as Types>::Chooser as Types>::Sampler as Types>::Weights: Unpin, <<<T as Types>::Chooser as Types>::Sampler as Types>::S: Unpin, <<<T as Types>::Chooser as Types>::Sampler as Types>::L: Unpin,

§

impl<'a, T> UnwindSafe for BaseEncoder<'a, T>
where <T as Types>::Data: UnwindSafe, <T as Types>::Indexes: UnwindSafe, <<T as Types>::Chooser as Types>::Indexes: UnwindSafe, <<T as Types>::Chooser as Types>::Shuffled: UnwindSafe, <<<T as Types>::Chooser as Types>::Sampler as Types>::Aliases: UnwindSafe, <<<T as Types>::Chooser as Types>::Sampler as Types>::Probs: UnwindSafe, <<<T as Types>::Chooser as Types>::Sampler as Types>::Weights: UnwindSafe, <<<T as Types>::Chooser as Types>::Sampler as Types>::S: UnwindSafe, <<<T as Types>::Chooser as Types>::Sampler as Types>::L: 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.