pub struct Channel { /* private fields */ }Expand description
Window-based reliable messaging channel.
Follows the action-queue model: send/receive/tick return
Vec<ChannelAction>. The caller dispatches actions.
Implementations§
Source§impl Channel
impl Channel
Sourcepub fn is_ready_to_send(&self) -> bool
pub fn is_ready_to_send(&self) -> bool
Check if channel is ready to send (has window capacity).
Sourcepub fn send(
&mut self,
msgtype: u16,
payload: &[u8],
now: f64,
link_mdu: usize,
) -> Result<Vec<ChannelAction>, ChannelError>
pub fn send( &mut self, msgtype: u16, payload: &[u8], now: f64, link_mdu: usize, ) -> Result<Vec<ChannelAction>, ChannelError>
Send a message. Returns SendOnLink action with packed envelope.
Sourcepub fn receive(&mut self, raw: &[u8], _now: f64) -> Vec<ChannelAction>
pub fn receive(&mut self, raw: &[u8], _now: f64) -> Vec<ChannelAction>
Receive decrypted envelope bytes.
Returns MessageReceived for contiguous sequences starting from
next_rx_sequence.
Sourcepub fn flush_tx(&mut self)
pub fn flush_tx(&mut self)
Clear all outstanding TX entries, restoring the window to full capacity. Used after holepunch completion where signaling messages are fire-and-forget.
Sourcepub fn packet_delivered(&mut self, sequence: Sequence) -> Vec<ChannelAction>
pub fn packet_delivered(&mut self, sequence: Sequence) -> Vec<ChannelAction>
Notify that a packet with given sequence was delivered (acknowledged).
Sourcepub fn packet_timeout(
&mut self,
sequence: Sequence,
now: f64,
) -> Vec<ChannelAction>
pub fn packet_timeout( &mut self, sequence: Sequence, now: f64, ) -> Vec<ChannelAction>
Notify that a packet with given sequence timed out.
Sourcepub fn get_packet_timeout(&self, tries: u8) -> f64
pub fn get_packet_timeout(&self, tries: u8) -> f64
Compute timeout duration for the given try count.
Formula: 1.5^(tries-1) * max(rtt*2.5, 0.025) * (tx_ring.len() + 1.5)
Sourcepub fn get_tries(&self, sequence: Sequence) -> Option<u8>
pub fn get_tries(&self, sequence: Sequence) -> Option<u8>
Get the current try count for a given sequence.
Sourcepub fn window_max(&self) -> u16
pub fn window_max(&self) -> u16
Current maximum window size.
Sourcepub fn outstanding(&self) -> usize
pub fn outstanding(&self) -> usize
Number of outstanding (undelivered) envelopes in TX ring.