pub struct Apdu { /* private fields */ }
Expand description
APDU stands for “smart card Application Protocol Data Unit”. This union definition is used by upstream’s library to alternate between treating APDU data in a structured or unstructured way.
Implementations§
source§impl Apdu
impl Apdu
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_pieces( cla: u8, ins: u8, p1: u8, p2: u8, lc: u8, data: &[u8] ) -> Result<Self>
sourcepub fn new_aid() -> Result<Self>
pub fn new_aid() -> Result<Self>
Construct a new Application ID APDU, which should be sent to the underlying hardware when we connect to it.
sourcepub fn raw(&self) -> &[u8] ⓘ
pub fn raw(&self) -> &[u8] ⓘ
Return this APDU’s raw data, including the various properties which are
normally broken out (e.g., this function returns more bytes than
data
).
sourcepub fn raw_minimal(&self) -> &[u8] ⓘ
pub fn raw_minimal(&self) -> &[u8] ⓘ
Returns the same data as raw
, but it excludes the extra tailing 0
bytes (i.e., it only includes the APDU’s properties along with lc
bytes of arbitrary data).
sourcepub fn cla(&self) -> u8
pub fn cla(&self) -> u8
Instruction class - indicates the type of command, e.g. interindustry or proprietary.
sourcepub fn p1(&self) -> u8
pub fn p1(&self) -> u8
First instruction parameter for the command, e.g. offset into file at which to write the data.
sourcepub fn p2(&self) -> u8
pub fn p2(&self) -> u8
Second instruction parameter for the command, e.g. offset into file at which to write the data.
sourcepub fn lc(&self) -> u8
pub fn lc(&self) -> u8
Encodes the number (N_c) of bytes of command data to follow. The official specification says that this field can be variable length, but upstream specifies it statically at 1 byte.
sourcepub fn data(&self) -> &[u8] ⓘ
pub fn data(&self) -> &[u8] ⓘ
The command data. The official specification says this can be up to 65535 bytes long, but upstream defines it as a static 255 bytes.
sourcepub fn data_minimal(&self) -> &[u8] ⓘ
pub fn data_minimal(&self) -> &[u8] ⓘ
Returns the same data as data
, but it excludes the extra trailing 0
bytes (i.e., it only includes lc
bytes or arbitrary data).
Trait Implementations§
source§impl PartialEq for Apdu
impl PartialEq for Apdu
impl Copy for Apdu
impl Eq for Apdu
Auto Trait Implementations§
impl RefUnwindSafe for Apdu
impl Send for Apdu
impl Sync for Apdu
impl Unpin for Apdu
impl UnwindSafe for Apdu
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.