BaseDecoder

Struct BaseDecoder 

Source
pub struct BaseDecoder<T: Types> { /* private fields */ }
Expand description

A decoder capable of receiving and recombining fountain-encoded transmissions.

§Examples

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

Implementations§

Source§

impl<const MAX_MESSAGE_LEN: usize, const MAX_MIXED_PARTS: usize, const MAX_FRAGMENT_LEN: usize, const MAX_SEQUENCE_COUNT: usize, const QUEUE_SIZE: usize> BaseDecoder<Heapless<MAX_MESSAGE_LEN, MAX_MIXED_PARTS, MAX_FRAGMENT_LEN, MAX_SEQUENCE_COUNT, QUEUE_SIZE>>

Source

pub const fn new() -> Self

Constructs a new HeaplessDecoder.

Source§

impl<T: Types> BaseDecoder<T>

Source

pub fn receive(&mut self, part: &Part<'_>) -> Result<bool, Error>

Receives a fountain-encoded part into the decoder.

§Examples

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

§Errors

If the part would fail validate because it is inconsistent with previously received parts, an error will be returned.

Source

pub fn is_part_consistent(&self, part: &Part<'_>) -> bool

Checks whether a Part is receivable by the decoder.

This can fail if other parts were previously received whose metadata (such as number of segments) is inconsistent with the present Part. Note that a fresh decoder will always return false here.

Source

pub fn message(&self) -> Result<Option<&[u8]>, Error>

If complete, returns the decoded message, None otherwise.

§Errors

If an inconsistent internal state is detected, an error will be returned.

§Examples

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

Source

pub fn is_complete(&self) -> bool

Returns whether the decoder is complete and hence the message available.

§Examples

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

Source

pub fn estimated_percent_complete(&self) -> f64

Calculate estimated percentage of completion.

Source

pub fn is_empty(&self) -> bool

Returns true if the decoder doesn’t contain any data.

Once a part is successfully received this method will return false.

Source

pub fn clear(&mut self)

Clear the decoder so that it can be used again.

Trait Implementations§

Source§

impl<T: Default + Types> Default for BaseDecoder<T>

Source§

fn default() -> BaseDecoder<T>

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

Auto Trait Implementations§

§

impl<T> Freeze for BaseDecoder<T>
where <T as Types>::Message: Freeze, <T as Types>::MixedParts: Freeze, <T as Types>::Indexes: Freeze, <T as Types>::Queue: 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<T> RefUnwindSafe for BaseDecoder<T>

§

impl<T> Send for BaseDecoder<T>
where <T as Types>::Message: Send, <T as Types>::MixedParts: Send, <T as Types>::Indexes: Send, <T as Types>::Queue: 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<T> Sync for BaseDecoder<T>
where <T as Types>::Message: Sync, <T as Types>::MixedParts: Sync, <T as Types>::Indexes: Sync, <T as Types>::Queue: 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<T> Unpin for BaseDecoder<T>
where <T as Types>::Message: Unpin, <T as Types>::MixedParts: Unpin, <T as Types>::Indexes: Unpin, <T as Types>::Queue: 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<T> UnwindSafe for BaseDecoder<T>

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.