Struct foundation_ur::BaseDecoder

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

A uniform resource decoder able to receive URIs that encode a fountain part.

§Examples

See the crate 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, const MAX_UR_TYPE: usize> BaseDecoder<Heapless<MAX_MESSAGE_LEN, MAX_MIXED_PARTS, MAX_FRAGMENT_LEN, MAX_SEQUENCE_COUNT, QUEUE_SIZE, MAX_UR_TYPE>>

source

pub const fn new() -> Self

Construct a new HeaplessDecoder.

source§

impl<T: Types> BaseDecoder<T>

source

pub fn receive<'a>(&mut self, ur: UR<'_>) -> Result<(), Error>

Receives a URI representing a CBOR and bytewords-encoded fountain part into the decoder.

§Examples

See the crate module documentation for examples.

§Errors

This function may error along all the necessary decoding steps:

  • The string may not be a well-formed URI according to the uniform resource scheme
  • The URI payload may not be a well-formed bytewords string
  • The decoded byte payload may not be valid CBOR
  • The CBOR-encoded fountain part may be inconsistent with previously received ones

In all these cases, an error will be returned.

source

pub fn is_complete(&self) -> bool

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

§Examples

See the crate module documentation for an example.

source

pub fn ur_type(&self) -> Option<&str>

Returns the UR type.

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 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.

§Examples
let decoder: HeaplessDecoder<8, 8, 8, 8, 8> = HeaplessDecoder::new();
assert!(decoder.is_empty());
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>::Fragment: Freeze, <T as Types>::URType: Freeze, <<T as Types>::Decoder as Types>::Message: Freeze, <<T as Types>::Decoder as Types>::MixedParts: Freeze, <<T as Types>::Decoder as Types>::Indexes: Freeze, <<T as Types>::Decoder as Types>::Queue: Freeze, <<<T as Types>::Decoder as Types>::Chooser as Types>::Indexes: Freeze, <<<T as Types>::Decoder as Types>::Chooser as Types>::Shuffled: Freeze, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::Aliases: Freeze, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::Probs: Freeze, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::Weights: Freeze, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::S: Freeze, <<<<T as Types>::Decoder 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>::Fragment: Send, <T as Types>::URType: Send, <<T as Types>::Decoder as Types>::Message: Send, <<T as Types>::Decoder as Types>::MixedParts: Send, <<T as Types>::Decoder as Types>::Indexes: Send, <<T as Types>::Decoder as Types>::Queue: Send, <<<T as Types>::Decoder as Types>::Chooser as Types>::Indexes: Send, <<<T as Types>::Decoder as Types>::Chooser as Types>::Shuffled: Send, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::Aliases: Send, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::Probs: Send, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::Weights: Send, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::S: Send, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::L: Send,

§

impl<T> Sync for BaseDecoder<T>
where <T as Types>::Fragment: Sync, <T as Types>::URType: Sync, <<T as Types>::Decoder as Types>::Message: Sync, <<T as Types>::Decoder as Types>::MixedParts: Sync, <<T as Types>::Decoder as Types>::Indexes: Sync, <<T as Types>::Decoder as Types>::Queue: Sync, <<<T as Types>::Decoder as Types>::Chooser as Types>::Indexes: Sync, <<<T as Types>::Decoder as Types>::Chooser as Types>::Shuffled: Sync, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::Aliases: Sync, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::Probs: Sync, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::Weights: Sync, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::S: Sync, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::L: Sync,

§

impl<T> Unpin for BaseDecoder<T>
where <T as Types>::Fragment: Unpin, <T as Types>::URType: Unpin, <<T as Types>::Decoder as Types>::Message: Unpin, <<T as Types>::Decoder as Types>::MixedParts: Unpin, <<T as Types>::Decoder as Types>::Indexes: Unpin, <<T as Types>::Decoder as Types>::Queue: Unpin, <<<T as Types>::Decoder as Types>::Chooser as Types>::Indexes: Unpin, <<<T as Types>::Decoder as Types>::Chooser as Types>::Shuffled: Unpin, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::Aliases: Unpin, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::Probs: Unpin, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::Weights: Unpin, <<<<T as Types>::Decoder as Types>::Chooser as Types>::Sampler as Types>::S: Unpin, <<<<T as Types>::Decoder 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>,

§

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>,

§

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.