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, const MAX_FRAGMENT_LEN: usize, const MAX_SEQUENCE_COUNT: usize> BaseEncoder<'a, Heapless<MAX_FRAGMENT_LEN, MAX_SEQUENCE_COUNT>>
impl<'a, const MAX_FRAGMENT_LEN: usize, const MAX_SEQUENCE_COUNT: usize> BaseEncoder<'a, Heapless<MAX_FRAGMENT_LEN, MAX_SEQUENCE_COUNT>>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Constructs a new HeaplessEncoder.
Source§impl<'a, T: Types> BaseEncoder<'a, T>
impl<'a, T: Types> BaseEncoder<'a, T>
Sourcepub fn start(&mut self, message: &'a [u8], max_fragment_length: usize)
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::Datacan hold.
Sourcepub fn current_sequence(&self) -> u32
pub fn current_sequence(&self) -> u32
Returns the current count of how many parts have been emitted.
Sourcepub fn sequence_count(&self) -> u32
pub fn sequence_count(&self) -> u32
Returns the number of segments the original message has been split up into.
Sourcepub fn is_complete(&self) -> bool
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.
Sourcepub fn next_part(&mut self) -> Part<'_>
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>where
<T as Types>::Data: RefUnwindSafe,
<T as Types>::Indexes: RefUnwindSafe,
<<T as Types>::Chooser as Types>::Indexes: RefUnwindSafe,
<<T as Types>::Chooser as Types>::Shuffled: RefUnwindSafe,
<<<T as Types>::Chooser as Types>::Sampler as Types>::Aliases: RefUnwindSafe,
<<<T as Types>::Chooser as Types>::Sampler as Types>::Probs: RefUnwindSafe,
<<<T as Types>::Chooser as Types>::Sampler as Types>::Weights: RefUnwindSafe,
<<<T as Types>::Chooser as Types>::Sampler as Types>::S: RefUnwindSafe,
<<<T as Types>::Chooser as Types>::Sampler as Types>::L: RefUnwindSafe,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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