pub struct AdmissionReceiver<T> { /* private fields */ }Expand description
Opt-in, one-consumer receiver with exact queue-depth accounting.
Created by NetworkLayer::start_with_admission or
NetworkLayer::enable_network_control_receiver_with_admission, or by
RouterOptions::track_admission or
RouterOptions::network_control_receiver_with_admission. The queue
holds 256 items; tracked APDUs additionally have a quota of 16 queued items per
source MAC (NetworkLayer) or (ingress port network number, source MAC) (router).
Controls have no per-source quota. Closed > fairness > Full determines
drop attribution; an admission drop releases the arriving payload, metadata
and reply sender without reply bytes or a wire rejection, never evicting an
older item. See the receive-queue contract
for exact keys, the raw/tracked matrix, queue independence and lifecycle.
Self::close retains queued items for draining; dropping this receiver
discards them and sets depth to zero without counting admission drops.
High-water/drop totals survive through an owned Self::counters handle.
This wrapper deliberately does not expose the underlying receiver: all
dequeues must update the snapshot. Use NetworkLayer::start for the
raw ApduReceiver, a router started without
RouterOptions::track_admission
for a plain mpsc::Receiver, or
NetworkLayer::enable_network_control_receiver for raw controls.
Implementations§
Source§impl<T> AdmissionReceiver<T>
impl<T> AdmissionReceiver<T>
Sourcepub fn counters(&self) -> QueueAdmissionCounters
pub fn counters(&self) -> QueueAdmissionCounters
Obtain an independently owned snapshot handle for this queue.
The clone shares accounting without retaining the receiver, payloads or
dispatch task, and remains readable after receiver/layer/router drop.
See QueueAdmissionCounters::snapshot and the
receive-queue contract.
Sourcepub async fn recv(&mut self) -> Option<T>
pub async fn recv(&mut self) -> Option<T>
Receive the next item, or None once closed and drained.
Returning an item releases one depth slot and, for tracked APDUs, one
source-key slot before the consumer can retain or process it. None
changes no counts. The key and limits follow the
receive-queue contract.
Cancellation safe: dropping a pending receive does not remove an item
or alter its accounting. No counter lock is held while waiting.
Sourcepub fn try_recv(&mut self) -> Result<T, TryRecvError>
pub fn try_recv(&mut self) -> Result<T, TryRecvError>
Receive immediately, releasing depth and source-key slots as in Self::recv.
A closed queue can still return queued items. Returns Empty when no item
is currently available but admission remains open, or Disconnected once
closed and drained. Errors do not change counts. See the
receive-queue contract.
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Stop admission while retaining already queued items for draining.
Depth and source-key slots remain until Self::recv or Self::try_recv
dequeues an item, or the receiver is dropped. Close itself does not count
as a drop or reset high-water/drop totals. Later attempts count as Closed,
taking precedence over fairness and Full.
In NetworkLayer, the next APDU admission attempt ends dispatch, or the next control admission attempt disables only that stream. Routers count every closed local admission attempt and keep forwarding/handling controls. These match closing the corresponding raw receiver. See the receive-queue contract.