Skip to main content

ApduReceiver

Struct ApduReceiver 

Source
pub struct ApduReceiver { /* private fields */ }
Expand description

The APDUs a NetworkLayer receives, from NetworkLayer::start.

Each recv takes the transport’s next NPDUs and decodes them in the caller’s task until one carries an APDU. Network messages met on the way go to the control receiver, if one was enabled, so controls flow only while this receiver is polled: while its consumer is busy in an inline await they wait in the transport’s queue, which adds latency but cannot deadlock. That queue is the only buffer: under overload it bounds memory, and the transport counts the NPDUs it drops. See the receive-queue contract.

NetworkLayer::stop, or dropping the layer, closes the transport’s queue: the receiver yields what was queued before then, then None, even when the transport keeps its sender alive.

Implementations§

Source§

impl ApduReceiver

Source

pub async fn recv(&mut self) -> Option<ReceivedApdu>

Receive the next APDU, or None once the transport’s queue is closed, by a stop or Self::close, and every NPDU in it has been taken.

Cancel safe, so it can sit in a select!: the only wait is the transport queue’s own receive, and an NPDU taken from it is decoded and handed on before this returns or waits again. Dropping the future loses nothing, and it holds no lock while it waits.

Source

pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<ReceivedApdu>>

Poll for the next APDU, as Self::recv does.

Source

pub fn try_recv(&mut self) -> Result<ReceivedApdu, TryRecvError>

Receive an APDU the transport has already queued, without waiting. Empty means none is queued now; Disconnected, that the queue is closed and drained.

Source

pub fn close(&mut self)

Stop the transport handing up more NPDUs, keeping those it already queued for Self::recv to drain.

Source

pub fn is_closed(&self) -> bool

Whether the transport can no longer hand up NPDUs: the layer stopped, or this receiver was closed. Queued ones may remain.

Trait Implementations§

Source§

impl Debug for ApduReceiver

Source§

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

Formats the value using the given formatter. Read more

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