BaseEncoder

Struct BaseEncoder 

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

A uniform resource encoder with an underlying fountain encoding.

§Examples

See the crate documentation for an example.

Implementations§

Source§

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

Source

pub const fn new() -> Self

Construct a new Encoder.

Source§

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

Source

pub const fn new() -> Self

Construct a new HeaplessEncoder.

Source§

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

Source

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

Creates a new encoder for the given message payload.

The emitted fountain parts will respect the maximum fragment length argument.

§Examples

See the crate documentation for an example.

§Panics

This function panics if ur_type or message is empty, or if max_fragment_length is zero.

Source

pub fn current_sequence(&self) -> u32

Returns the current count of already emitted parts.

§Examples
encoder.start("bytes", "data".as_bytes(), 5);

assert_eq!(encoder.current_sequence(), 0);
encoder.next_part();
assert_eq!(encoder.current_sequence(), 1);
Source

pub fn sequence_count(&self) -> u32

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

§Examples
encoder.start("bytes", "data".as_bytes(), 3);
assert_eq!(encoder.sequence_count(), 2);
Source

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

Returns the URI corresponding to next fountain part.

§Examples

See the crate documentation for an example.

Auto Trait Implementations§

§

impl<'a, 'b, T> Freeze for BaseEncoder<'a, 'b, 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, 'b, T> RefUnwindSafe for BaseEncoder<'a, 'b, T>

§

impl<'a, 'b, T> Send for BaseEncoder<'a, 'b, 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, 'b, T> Sync for BaseEncoder<'a, 'b, 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, 'b, T> Unpin for BaseEncoder<'a, 'b, 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, 'b, T> UnwindSafe for BaseEncoder<'a, 'b, 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.