Skip to main content

Channel

Struct Channel 

Source
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

Source

pub fn new(initial_rtt: f64) -> Self

Create a new Channel with initial RTT.

Source

pub fn set_rtt(&mut self, rtt: f64)

Update the RTT value.

Source

pub fn mdu(&self, link_mdu: usize) -> usize

Maximum data unit available for message payload.

Source

pub fn is_ready_to_send(&self) -> bool

Check if channel is ready to send (has window capacity).

Source

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.

Source

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.

Source

pub fn packet_delivered(&mut self, sequence: Sequence) -> Vec<ChannelAction>

Notify that a packet with given sequence was delivered (acknowledged).

Source

pub fn packet_timeout( &mut self, sequence: Sequence, now: f64, ) -> Vec<ChannelAction>

Notify that a packet with given sequence timed out.

Source

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)

Source

pub fn get_tries(&self, sequence: Sequence) -> Option<u8>

Get the current try count for a given sequence.

Source

pub fn shutdown(&mut self)

Shut down the channel, clearing all rings.

Source

pub fn window(&self) -> u16

Current window size.

Source

pub fn window_max(&self) -> u16

Current maximum window size.

Source

pub fn outstanding(&self) -> usize

Number of outstanding (undelivered) envelopes in TX ring.

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> Same for T

Source§

type Output = T

Should always be Self
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.