Skip to main content

RlcEncoder

Struct RlcEncoder 

Source
pub struct RlcEncoder { /* private fields */ }
Expand description

Sliding-window RLC encoder: holds the last window_max source symbols and emits one repair symbol every step source symbols.

Implementations§

Source§

impl RlcEncoder

Source

pub fn new(window_max: usize, step: usize, dt: u8, symbol_len: usize) -> Self

Build an encoder over symbol_len-byte symbols with a window of up to window_max source symbols, emitting one repair every step source symbols at density threshold dt. The code rate is step / (step + 1).

Source

pub fn set_params(&mut self, window_max: usize, step: usize, dt: u8)

Retune the coding parameters at runtime (the adaptive control path): the window size, the repair cadence step (code rate step / (step + 1)), and the coefficient density dt. Shrinking the window trims the oldest source symbols immediately so the next repair spans only the new window.

Source

pub fn set_coding(&mut self, on: bool)

Turn repair emission on or off (disable-on-clean). The window keeps filling either way, so re-enabling protects the in-flight symbols at once.

Source

pub fn params(&self) -> (usize, usize, u8)

The live (window_max, step, dt) parameters (telemetry).

Source

pub fn coding_on(&self) -> bool

Whether repair emission is currently active.

Source

pub fn push_source(&mut self, payload: &[u8]) -> (u32, Option<RepairSymbol>)

Add one source symbol. Returns its assigned source id and, every step symbols (while coding is on), a repair symbol to interleave onto the wire after it.

Source

pub fn forget_below(&mut self, floor: u32)

Drop acknowledged-or-recovered source symbols below floor from the window (the elastic-window feedback path); the window never protects data the peer already has.

Source

pub fn rebase_to(&mut self, base: u32)

Re-base the source-id stream to base for a cross-code resync: the next source symbol is assigned id base and the coding window starts empty, so repairs reference only post-rebase symbols. Used when another code carried the ids between this code’s old running id and base, so it must resume at base rather than its own (now-diverged) counter. The repair-key counter keeps running (keys are matched to ids by coefficient, not by equality).

Source

pub fn next_source_id(&self) -> u32

The next source id that will be assigned.

Trait Implementations§

Source§

impl Debug for RlcEncoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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