Skip to main content

CompressedSender

Struct CompressedSender 

Source
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

Source

pub fn new(inner: ReliableUdpSender, tpl: SchemaTemplate) -> Self

Wrap an existing sender with a learned template.

Source

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

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn flow_blocked(&self) -> bool

True while the FEC flow window is full (delegates to the inner sender). Pair with pump_feedback.

Source

pub fn pump_feedback(&mut self) -> Result<()>

Drain inbound feedback (acks / NAKs), advancing the flow window.

Source

pub fn flush(&mut self) -> Result<()>

Flush the pending coalesce batch, then the final partial FEC block.

Source

pub fn drain_until_acked(&mut self, timeout: Duration) -> Result<bool>

Block until every shipped block is acknowledged or timeout.

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.