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 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.
Auto Trait Implementations§
impl Freeze for Channel
impl RefUnwindSafe for Channel
impl Send for Channel
impl Sync for Channel
impl Unpin for Channel
impl UnwindSafe for Channel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more