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>
impl<const MAX_SYMBOL_SIZE: usize, const MAX_WINDOW_SYMBOLS: usize> Encoder<MAX_SYMBOL_SIZE, MAX_WINDOW_SYMBOLS>
Sourcepub fn new(
config: RlcConfig,
initial_esi: EncodingSymbolId,
) -> Result<Self, Error>
pub fn new( config: RlcConfig, initial_esi: EncodingSymbolId, ) -> Result<Self, Error>
Creates an empty encoder whose first source symbol uses initial_esi.
Sourcepub const fn window_len(&self) -> usize
pub const fn window_len(&self) -> usize
Returns the number of source symbols currently retained.
Sourcepub const fn window(&self) -> Option<(EncodingSymbolId, usize)>
pub const fn window(&self) -> Option<(EncodingSymbolId, usize)>
Returns the ESI and length of the current encoding window.
Sourcepub const fn next_esi(&self) -> EncodingSymbolId
pub const fn next_esi(&self) -> EncodingSymbolId
Returns the ESI that will be assigned by the next push_source.
Sourcepub fn push_source(&mut self, symbol: &[u8]) -> Result<EncodingSymbolId, Error>
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.
Sourcepub fn discard_oldest(&mut self, count: usize)
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.
Sourcepub fn encode_repair(
&self,
parameters: RepairParameters,
output: &mut [u8],
) -> Result<RepairPayloadId, Error>
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.