Skip to main content

ApduHeader

Enum ApduHeader 

Source
#[non_exhaustive]
pub enum ApduHeader { ConfirmedRequest(ConfirmedRequestHeader), UnconfirmedRequest(UnconfirmedServiceChoice), ComplexAck { invoke_id: u8, service_choice: ConfirmedServiceChoice, }, Error { invoke_id: u8, service_choice: ConfirmedServiceChoice, }, Reject { invoke_id: u8, reason: RejectReason, }, Abort { server: bool, invoke_id: u8, reason: AbortReason, }, }
Expand description

The header of an APDU that carries service parameters, or the whole of a Reject or an Abort, as the allocation-free profile reads and writes it.

More PDU types may join it, so a match on it needs a wildcard arm.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

ConfirmedRequest(ConfirmedRequestHeader)

An unsegmented Confirmed-Request: four octets.

§

UnconfirmedRequest(UnconfirmedServiceChoice)

An Unconfirmed-Request for this service: two octets.

§

ComplexAck

An unsegmented ComplexACK: three octets.

Fields

§invoke_id: u8

The invoke ID of the request it answers.

§service_choice: ConfirmedServiceChoice

The service it answers.

§

Error

The header of an Error: three octets, followed by the error parameters (for most services, the application-tagged error class and code).

Fields

§invoke_id: u8

The invoke ID of the request it answers.

§service_choice: ConfirmedServiceChoice

The service that failed.

§

Reject

A whole Reject: three octets, with no parameters after them.

Fields

§invoke_id: u8

The invoke ID of the request it rejects.

§reason: RejectReason

Why.

§

Abort

A whole Abort: three octets, with no parameters after them.

Fields

§server: bool

Whether the server sent it (the SRV bit), rather than the client.

§invoke_id: u8

Which transaction it ends, by invoke ID.

§reason: AbortReason

Why.

Implementations§

Source§

impl ApduHeader

Source

pub fn decode(apdu: &[u8]) -> Result<(Self, &[u8]), Error>

Split apdu into its header and the service parameters after it.

Refuses, at offset 0 unless noted: an empty APDU; one whose header is cut short (Error::BufferTooShort); a reserved max-APDU code (at offset 1), segmented or not; a segmented Confirmed-Request or ComplexACK, a SimpleACK and a SegmentACK, with DecodingKind::Unsupported; and a PDU type nibble past 7. The more-follows bit of an unsegmented PDU is ignored, as Clause 20.1.2.2 asks, and so are the reserved bits of an Error, a Reject or an Abort. A Reject or an Abort is the whole PDU: what follows its three octets is returned as the parameters, for the caller to refuse.

Source

pub const fn encoded_len(&self) -> usize

The header’s length in octets: 4 for a Confirmed-Request, 2 for an Unconfirmed-Request and 3 for the rest.

Source

pub fn encode_to_sink<S: EncodeSink + ?Sized>( &self, sink: &mut S, ) -> Result<usize, SinkFull>

Append the header in one write; returns the octets appended.

Source

pub fn encode_with_parameters_to_sink<S: EncodeSink + ?Sized>( &self, sink: &mut S, parameters: &[u8], ) -> Result<usize, SinkFull>

Append the header and the service parameters after it as one value (EncodeSink::write_parts); returns the octets appended.

Trait Implementations§

Source§

impl Clone for ApduHeader

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ApduHeader

Source§

impl Debug for ApduHeader

Source§

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

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

impl Eq for ApduHeader

Source§

impl Hash for ApduHeader

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ApduHeader

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ApduHeader

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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