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
impl RlcEncoder
Sourcepub fn new(window_max: usize, step: usize, dt: u8, symbol_len: usize) -> Self
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).
Sourcepub fn set_params(&mut self, window_max: usize, step: usize, dt: u8)
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.
Sourcepub fn set_coding(&mut self, on: bool)
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.
Sourcepub fn params(&self) -> (usize, usize, u8)
pub fn params(&self) -> (usize, usize, u8)
The live (window_max, step, dt) parameters (telemetry).
Sourcepub fn push_source(&mut self, payload: &[u8]) -> (u32, Option<RepairSymbol>)
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.
Sourcepub fn forget_below(&mut self, floor: u32)
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.
Sourcepub fn rebase_to(&mut self, base: u32)
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).
Sourcepub fn next_source_id(&self) -> u32
pub fn next_source_id(&self) -> u32
The next source id that will be assigned.