Skip to main content

Encoder

Struct Encoder 

Source
pub struct Encoder<const MAX_SYMBOL_SIZE: usize, const MAX_WINDOW_SYMBOLS: usize> { /* private fields */ }
Expand description

A systematic, bounded sliding-window RFC 8681 encoder.

MAX_SYMBOL_SIZE and MAX_WINDOW_SYMBOLS are hard memory capacities. The active sizes come from RlcConfig and may be smaller.

Implementations§

Source§

impl<const MAX_SYMBOL_SIZE: usize, const MAX_WINDOW_SYMBOLS: usize> Encoder<MAX_SYMBOL_SIZE, MAX_WINDOW_SYMBOLS>

Source

pub fn new( config: RlcConfig, initial_esi: EncodingSymbolId, ) -> Result<Self, Error>

Creates an empty encoder whose first source symbol uses initial_esi.

Source

pub const fn config(&self) -> RlcConfig

Returns the active configuration.

Source

pub const fn window_len(&self) -> usize

Returns the number of source symbols currently retained.

Source

pub const fn window(&self) -> Option<(EncodingSymbolId, usize)>

Returns the ESI and length of the current encoding window.

Source

pub const fn next_esi(&self) -> EncodingSymbolId

Returns the ESI that will be assigned by the next push_source.

Source

pub fn push_source(&mut self, symbol: &[u8]) -> Result<EncodingSymbolId, Error>

Copies a source symbol into the encoding window and returns its ESI.

Once the active window is full, this evicts exactly one oldest symbol.

Source

pub fn discard_oldest(&mut self, count: usize)

Removes up to count oldest symbols from the coding window.

This supports application-level validity expiry in addition to automatic eviction at the configured window size.

Source

pub fn encode_repair( &self, parameters: RepairParameters, output: &mut [u8], ) -> Result<RepairPayloadId, Error>

Encodes one repair symbol for the current window.

The returned value contains all metadata needed to regenerate the coding coefficients. The caller owns packetization and transport.

Auto Trait Implementations§

§

impl<const MAX_SYMBOL_SIZE: usize, const MAX_WINDOW_SYMBOLS: usize> Freeze for Encoder<MAX_SYMBOL_SIZE, MAX_WINDOW_SYMBOLS>

§

impl<const MAX_SYMBOL_SIZE: usize, const MAX_WINDOW_SYMBOLS: usize> RefUnwindSafe for Encoder<MAX_SYMBOL_SIZE, MAX_WINDOW_SYMBOLS>

§

impl<const MAX_SYMBOL_SIZE: usize, const MAX_WINDOW_SYMBOLS: usize> Send for Encoder<MAX_SYMBOL_SIZE, MAX_WINDOW_SYMBOLS>

§

impl<const MAX_SYMBOL_SIZE: usize, const MAX_WINDOW_SYMBOLS: usize> Sync for Encoder<MAX_SYMBOL_SIZE, MAX_WINDOW_SYMBOLS>

§

impl<const MAX_SYMBOL_SIZE: usize, const MAX_WINDOW_SYMBOLS: usize> Unpin for Encoder<MAX_SYMBOL_SIZE, MAX_WINDOW_SYMBOLS>

§

impl<const MAX_SYMBOL_SIZE: usize, const MAX_WINDOW_SYMBOLS: usize> UnsafeUnpin for Encoder<MAX_SYMBOL_SIZE, MAX_WINDOW_SYMBOLS>

§

impl<const MAX_SYMBOL_SIZE: usize, const MAX_WINDOW_SYMBOLS: usize> UnwindSafe for Encoder<MAX_SYMBOL_SIZE, MAX_WINDOW_SYMBOLS>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.