Skip to main content

AdmissionReceiver

Struct AdmissionReceiver 

Source
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>

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<T: Debug> Debug for AdmissionReceiver<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Drop for AdmissionReceiver<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl LocalApduReceiver for AdmissionReceiver<ReceivedApdu>

Source§

impl NetworkControlReceiver for AdmissionReceiver<ReceivedNetworkControl>

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more