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
impl ApduReceiver
Sourcepub async fn recv(&mut self) -> Option<ReceivedApdu>
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.
Sourcepub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<ReceivedApdu>>
pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<ReceivedApdu>>
Poll for the next APDU, as Self::recv does.
Sourcepub fn try_recv(&mut self) -> Result<ReceivedApdu, TryRecvError>
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.
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Stop the transport handing up more NPDUs, keeping those it already
queued for Self::recv to drain.