pub struct QueueFilter { /* private fields */ }Expand description
3-priority FIFO queue with WaitingForAck backpressure.
The QueueFilter classifies frames by priority and queues them when the target connection is in WaitingForAck state. This prevents frame loss from the server overwhelming the client before it has acknowledged the previous frame.
When backpressure is released (ACK received), queued frames are drained in strict priority order: High → Normal → Low.
Implementations§
Source§impl QueueFilter
impl QueueFilter
Sourcepub fn new(config: QueueFilterConfig) -> Self
pub fn new(config: QueueFilterConfig) -> Self
Create a new QueueFilter with the given configuration.
Sourcepub fn process_send(&self, envelope: &mut FrameEnvelope) -> FilterResult
pub fn process_send(&self, envelope: &mut FrameEnvelope) -> FilterResult
Process a frame in the send direction.
- Classify the frame’s priority based on message code
- If backpressure is active (WaitingForAck), queue the frame
- Otherwise, pass through with priority set on envelope
Sourcepub fn process_recv(&self, _envelope: &FrameEnvelope) -> FilterResult
pub fn process_recv(&self, _envelope: &FrameEnvelope) -> FilterResult
Process a frame in the recv direction.
On the receive path, we just pass through. The actual backpressure
release happens via on_ack_received().
Sourcepub fn set_waiting_for_ack(&self, channel_id: u8, waiting: bool)
pub fn set_waiting_for_ack(&self, channel_id: u8, waiting: bool)
Set a channel’s WaitingForAck backpressure flag.
Sourcepub fn on_ack_received(&self, channel_id: u8)
pub fn on_ack_received(&self, channel_id: u8)
Notify that an ACK was received for a channel.
This releases backpressure and allows queued frames to be drained.
Sourcepub fn on_send_error(&self, channel_id: u8)
pub fn on_send_error(&self, channel_id: u8)
Notify that a send error occurred for a channel.
This does not change backpressure state — the connection may retry.
Sourcepub fn has_pending(&self, channel_id: u8) -> bool
pub fn has_pending(&self, channel_id: u8) -> bool
Check if there are pending frames for a channel.
Sourcepub fn total_pending(&self) -> usize
pub fn total_pending(&self) -> usize
Get the total number of pending frames across all channels.
Sourcepub fn drain(&self, channel_id: u8, max_count: usize) -> Vec<FrameEnvelope>
pub fn drain(&self, channel_id: u8, max_count: usize) -> Vec<FrameEnvelope>
Drain up to max_count frames from a channel in priority order.
Returns frames in descending priority order: High → Normal → Low.
Sourcepub fn pending_by_priority(&self, channel_id: u8) -> [usize; 3]
pub fn pending_by_priority(&self, channel_id: u8) -> [usize; 3]
Get pending frame counts per priority for a channel.
Sourcepub fn clear_channel(&self, channel_id: u8)
pub fn clear_channel(&self, channel_id: u8)
Remove all queued frames for a channel (e.g., on disconnect).
Sourcepub fn stats_snapshot(&self) -> QueueFilterStatsSnapshot
pub fn stats_snapshot(&self) -> QueueFilterStatsSnapshot
Get a snapshot of the statistics.