Struct yubirs::piv::apdu::Apdu

source ·
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

source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

source

pub fn from_pieces( cla: u8, ins: u8, p1: u8, p2: u8, lc: u8, data: &[u8] ) -> Result<Self>

source

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.

source

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).

source

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).

source

pub fn cla(&self) -> u8

Instruction class - indicates the type of command, e.g. interindustry or proprietary.

source

pub fn ins(&self) -> u8

Instruction code - indicates the specific command, e.g. “write data”.

source

pub fn p1(&self) -> u8

First instruction parameter for the command, e.g. offset into file at which to write the data.

source

pub fn p2(&self) -> u8

Second instruction parameter for the command, e.g. offset into file at which to write the data.

source

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.

source

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.

source

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 Clone for Apdu

source§

fn clone(&self) -> Apdu

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Apdu

source§

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

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

impl PartialEq for Apdu

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Apdu

source§

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> 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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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,

§

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>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more