pub struct CompressedSender { /* private fields */ }Expand description
Sending half: tags and compresses each slot, ships the template first, and (optionally) re-learns it mid-stream.
Implementations§
Source§impl CompressedSender
impl CompressedSender
Sourcepub fn new(inner: ReliableUdpSender, tpl: SchemaTemplate) -> Self
pub fn new(inner: ReliableUdpSender, tpl: SchemaTemplate) -> Self
Wrap an existing sender with a learned template.
Sourcepub fn relearns(&self) -> usize
pub fn relearns(&self) -> usize
How many times the template has been re-learned mid-stream (the observable signal that the schema drifted and adaptation fired).
Sourcepub fn with_coalesce(self, target: usize) -> Self
pub fn with_coalesce(self, target: usize) -> Self
Coalesce many compressed slots into one transport item of up to
target bytes before the FEC encoder, so the datagram rate stops
bounding throughput on small slots (the stream bridges do the same,
256 slots per socket write). target should be near the FEC
max_item. A partial batch flushes on flush or a
re-learn. Off by default (one slot per item, lowest latency).
Sourcepub fn bind(
peer: SocketAddr,
k: usize,
r: usize,
max_item: usize,
tpl: SchemaTemplate,
) -> Result<Self>
pub fn bind( peer: SocketAddr, k: usize, r: usize, max_item: usize, tpl: SchemaTemplate, ) -> Result<Self>
Bind a fresh sender to peer with k+r FEC and a max_item
FEC payload (must hold the tagged serialized template and a
worst-case tagged escaped slot), wrapped with tpl.
Sourcepub fn with_relearn(self, window: usize, threshold_pct: u32) -> Self
pub fn with_relearn(self, window: usize, threshold_pct: u32) -> Self
Enable adaptive re-learning: keep the last window slots, and when
the escape rate over a window exceeds threshold_pct, re-learn the
template from those slots and ship the new one in-band.
Sourcepub fn send_item(&mut self, slot: &[u8]) -> Result<()>
pub fn send_item(&mut self, slot: &[u8]) -> Result<()>
Compress slot and ship it (tagged). The first call ships the
template; with re-learning on, a drifting schema triggers a new
template in-band.
Sourcepub fn flow_blocked(&self) -> bool
pub fn flow_blocked(&self) -> bool
True while the FEC flow window is full (delegates to the inner
sender). Pair with pump_feedback.
Sourcepub fn pump_feedback(&mut self) -> Result<()>
pub fn pump_feedback(&mut self) -> Result<()>
Drain inbound feedback (acks / NAKs), advancing the flow window.
Sourcepub fn flush(&mut self) -> Result<()>
pub fn flush(&mut self) -> Result<()>
Flush the pending coalesce batch, then the final partial FEC block.
Sourcepub fn drain_until_acked(&mut self, timeout: Duration) -> Result<bool>
pub fn drain_until_acked(&mut self, timeout: Duration) -> Result<bool>
Block until every shipped block is acknowledged or timeout.