#[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
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
service_choice: ConfirmedServiceChoiceThe 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
service_choice: ConfirmedServiceChoiceThe service that failed.
Reject
A whole Reject: three octets, with no parameters after them.
Abort
A whole Abort: three octets, with no parameters after them.
Implementations§
Source§impl ApduHeader
impl ApduHeader
Sourcepub fn decode(apdu: &[u8]) -> Result<(Self, &[u8]), Error>
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.
Sourcepub const fn encoded_len(&self) -> usize
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.
Sourcepub fn encode_to_sink<S: EncodeSink + ?Sized>(
&self,
sink: &mut S,
) -> Result<usize, SinkFull>
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.
Sourcepub fn encode_with_parameters_to_sink<S: EncodeSink + ?Sized>(
&self,
sink: &mut S,
parameters: &[u8],
) -> Result<usize, SinkFull>
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.