pub struct AckManager { /* private fields */ }Expand description
ACK manager for tracking pending acknowledgments.
Implementations§
Source§impl AckManager
impl AckManager
Sourcepub fn with_config(config: AckConfig) -> Self
pub fn with_config(config: AckConfig) -> Self
Creates a new ACK manager with custom configuration.
Sourcepub fn register_pending_ack(
&mut self,
message_id: MessageId,
timeout_ms: Option<u64>,
) -> Result<Option<AckEvictionInfo>>
pub fn register_pending_ack( &mut self, message_id: MessageId, timeout_ms: Option<u64>, ) -> Result<Option<AckEvictionInfo>>
Registers a message as waiting for ACK.
§Arguments
message_id- ID of the message waiting for ACKtimeout_ms- Optional custom timeout (uses default if None)
§Returns
Returns Ok(Some(info)) if a lower-priority ACK was evicted to make room,
Ok(None) if no eviction was needed, or Err if capacity is full and no
lower-priority ACK exists to evict.
Sourcepub fn register_pending_ack_with_priority(
&mut self,
message_id: MessageId,
timeout_ms: Option<u64>,
priority: MessagePriority,
) -> Result<Option<AckEvictionInfo>>
pub fn register_pending_ack_with_priority( &mut self, message_id: MessageId, timeout_ms: Option<u64>, priority: MessagePriority, ) -> Result<Option<AckEvictionInfo>>
Registers a message as waiting for ACK with specified priority.
§Arguments
message_id- ID of the message waiting for ACKtimeout_ms- Optional custom timeout (uses default if None)priority- Message priority for eviction decisions
§Returns
Returns Ok(Some(info)) if a lower-priority ACK was evicted to make room,
Ok(None) if no eviction was needed, or Err if capacity is full and no
lower-priority ACK exists to evict.
Sourcepub fn drain_timed_out(&mut self) -> Vec<PendingAck>
pub fn drain_timed_out(&mut self) -> Vec<PendingAck>
Returns all ACKs that have timed out and marks them as TimedOut.
Note: This does NOT remove entries from the map. Entries are kept so that:
increment_retry_count()can reset them when the message is retried- Late ACKs can still be matched via
remove_ack()
Entries are eventually removed by:
remove_ack()when ACK is received or max retries exceededprune_old_timeouts()for stale entries
Sourcepub fn remove_ack(&mut self, message_id: &MessageId) -> Option<PendingAck>
pub fn remove_ack(&mut self, message_id: &MessageId) -> Option<PendingAck>
Removes an ACK from tracking (e.g., after successful delivery).
Sourcepub fn get_timed_out_acks(&self) -> Vec<MessageId>
pub fn get_timed_out_acks(&self) -> Vec<MessageId>
Sourcepub fn increment_retry_count(&mut self, message_id: &MessageId)
pub fn increment_retry_count(&mut self, message_id: &MessageId)
Updates the retry count for a message.
Sourcepub fn extend_while_queued(
&mut self,
message_id: &MessageId,
max_wait: Duration,
) -> bool
pub fn extend_while_queued( &mut self, message_id: &MessageId, max_wait: Duration, ) -> bool
Gives a timed-out entry another full timeout because its frame has not
left the device yet, as long as the attempt is younger than
max_wait. Returns whether it was extended; false means the caller
retries it as usual.
The timer starts when a frame is queued, not when it is written, so on
a link carrying less than it is offered a frame can time out while it
is still waiting its turn. Retrying it then appends a second copy
behind the first, re-sealed under a fresh ratchet generation, which
makes the queue longer and the receiver’s gap wider. max_wait bounds
the grace so a queue that never drains still falls through to the retry
ladder and the other carriers.
Sourcepub fn set_retry_count(&mut self, message_id: &MessageId, retry_count: u32)
pub fn set_retry_count(&mut self, message_id: &MessageId, retry_count: u32)
Carry an accumulated retry count onto a pending ACK.
register_pending_ack* always starts a fresh ACK at retry_count: 0.
When a message is re-sent from the retry queue and its prior ACK had
already been cleared (the resend registers a brand-new ACK), that new ACK
would otherwise reset the backoff ladder to 0 — pinning delay_for_retry
at its 1s floor for a recipient that never ACKs (an offline peer), which
re-sends ~once per second forever. Seeding the new ACK with the count the
retry-queue entry already carries lets the exponential backoff advance
across resends. No-op if the message has no pending ACK.
Sourcepub fn get_pending_ack(&self, message_id: &MessageId) -> Option<&PendingAck>
pub fn get_pending_ack(&self, message_id: &MessageId) -> Option<&PendingAck>
Gets information about a pending ACK.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Gets the number of pending ACKs.
Sourcepub fn has_capacity_for(&self, message_id: &MessageId) -> bool
pub fn has_capacity_for(&self, message_id: &MessageId) -> bool
Whether registering message_id would succeed without evicting
anything: it is already tracked, or the table has a free slot.
A sender asks this before it transmits. Asking after is too late: the frame is on the wire, and the only honest outcomes left are to track it or to have refused it.
Sourcepub fn is_waiting_for_ack(&self, message_id: &MessageId) -> bool
pub fn is_waiting_for_ack(&self, message_id: &MessageId) -> bool
Checks if a message is waiting for ACK.
Sourcepub fn prune_old_timeouts(&mut self, older_than: Duration)
pub fn prune_old_timeouts(&mut self, older_than: Duration)
Removes all ACKs with TimedOut status that are older than a given duration.
This helps prevent unbounded memory growth.