pub struct TransmitQueue { /* private fields */ }Expand description
The chat transmit queue.
Frames go to the node through a bounded window, so a message larger than the window waits here rather than in the MAC’s own queue. A frame leaves the window when nothing more can happen to it: acknowledged or failed, or transmitted when no acknowledgment will follow.
Implementations§
Source§impl TransmitQueue
impl TransmitQueue
Sourcepub fn new(window: usize) -> Self
pub fn new(window: usize) -> Self
A queue keeping at most window frames in flight, aligned with the
MAC’s transmit queue.
pub fn enqueue(&mut self, outbound: Outbound)
pub fn has_pending(&self) -> bool
pub fn pending_len(&self) -> usize
pub fn in_flight_len(&self) -> usize
Sourcepub async fn pump<M, P, const SLOTS: usize, const PAGES: usize>(
&mut self,
node: &LocalNode<M>,
chat: &mut ChatFacade<P, SLOTS, PAGES>,
policy: &TransmitPolicy,
now_ms: u64,
) -> usizewhere
M: MacBackend,
P: TextProfile + Clone,
pub async fn pump<M, P, const SLOTS: usize, const PAGES: usize>(
&mut self,
node: &LocalNode<M>,
chat: &mut ChatFacade<P, SLOTS, PAGES>,
policy: &TransmitPolicy,
now_ms: u64,
) -> usizewhere
M: MacBackend,
P: TextProfile + Clone,
Hand waiting frames to the node while the window has room. Returns
how many were sent: each is an authenticated send that advanced the
frame counter. It is TransmitQueue::depart, transmit, and
TransmitQueue::departed in a loop, for a caller that holds the
facade across the sends.
Sourcepub fn depart(
&mut self,
channels: &ChannelRegistry,
policy: &TransmitPolicy,
) -> Option<Result<Departure, Undeliverable>>
pub fn depart( &mut self, channels: &ChannelRegistry, policy: &TransmitPolicy, ) -> Option<Result<Departure, Undeliverable>>
The next frame the window has room for, with where it goes resolved
against channels. None when nothing may leave now.
- A unicast asks for an acknowledgment, and a peer gets one frame in flight until its first is acknowledged: first contact may need counter synchronization. Until then it names us by full key, since a peer that has not registered us cannot read a frame that names us by hint.
- A channel multicast carries the full source key, so a member who misses a fragment can address a resend request to us.
- A channel-direct frame is a blind unicast, registering the peer on the way out.
EMERGENCYgoes out unencrypted, so any node in range can read it.
A frame on a channel no longer held comes back undeliverable.
Sourcepub fn departed(
&mut self,
departure: Departure,
sent: Sent,
now_ms: u64,
) -> Departed
pub fn departed( &mut self, departure: Departure, sent: Sent, now_ms: u64, ) -> Departed
What became of a departure’s send. A frame the node refused for now—with a registered peer and an engine-bounded payload, its queues are full—goes back to the head of the queue, to wait for tickets to advance.
Sourcepub fn service<P, const SLOTS: usize, const PAGES: usize>(
&mut self,
chat: &mut ChatFacade<P, SLOTS, PAGES>,
now_ms: u64,
) -> Vec<Stall>where
P: TextProfile + Clone,
pub fn service<P, const SLOTS: usize, const PAGES: usize>(
&mut self,
chat: &mut ChatFacade<P, SLOTS, PAGES>,
now_ms: u64,
) -> Vec<Stall>where
P: TextProfile + Clone,
Report what the tickets say to the engine: transmitted, acknowledged, or failed. Returns the frames newly found overdue.
Sourcepub fn fail_all<P, const SLOTS: usize, const PAGES: usize>(
&mut self,
chat: &mut ChatFacade<P, SLOTS, PAGES>,
now_ms: u64,
) -> Vec<SendReceipt>where
P: TextProfile + Clone,
pub fn fail_all<P, const SLOTS: usize, const PAGES: usize>(
&mut self,
chat: &mut ChatFacade<P, SLOTS, PAGES>,
now_ms: u64,
) -> Vec<SendReceipt>where
P: TextProfile + Clone,
Fail every frame the queue holds, waiting or in flight. Returns the receipts of in-flight sends still awaiting an acknowledgment, for the caller to cancel at the MAC.