Struct CommandBuilder

Source
pub struct CommandBuilder<D> {
    pub p1: u8,
    pub p2: u8,
    /* private fields */
}

Fields§

§p1: u8§p2: u8

Implementations§

Source§

impl<D: DataSource> CommandBuilder<D>

Source

pub fn new( class: Class, instruction: Instruction, p1: u8, p2: u8, data: D, le: impl Into<ExpectedLen>, ) -> Self

Panics if data.len() > u16::MAX

Assumes that extended length is supported

Source

pub fn force_extended(self) -> Self

Force the encoding of the APDU to be extended, even when the data and expected length are not neccessarily extended.

Source

pub fn data(&self) -> D
where D: Copy,

Source

pub fn required_len(&self) -> usize

Required length for serialization in only one command. Assumes extended length support

This can be useful to get the necessary dimension for the buffer to provide to serialize_into

Source

pub fn serialize_into<W: Writer>(&self, writer: &mut W) -> Result<(), W::Error>
where D: DataStream<W>,

This assumes that the writer has enough space to encode the APDU. If that might not be the case, first use should_split

Source§

impl<'a> CommandBuilder<&'a [u8]>

Source

pub fn new_non_extended( class: Class, instruction: Instruction, p1: u8, p2: u8, data: &'a [u8], le: u16, buffer_len: Option<usize>, ) -> ChainedCommandIterator<'a>

Panics if data.len() > u16::MAX

Assumes that extended length is supported

Source

pub fn should_split(&self, available_len: usize) -> Option<(Self, Self)>

Given the available length and the extended length support, split the command in 2 commands that use command chaining to be sent

None means that the command can we serialized withinn available_len without needing Chaining Some(command, rem) means that command can be sent within available_len and that rem must then be sent (for command chaining). Note that should_split should also be called on rem as more than 2 commands might be required.

In certain conditions can panic if available_len <= 9 since 9 is the minimum length required to encode the header and trailer of a command.

Trait Implementations§

Source§

impl<D: Clone> Clone for CommandBuilder<D>

Source§

fn clone(&self) -> CommandBuilder<D>

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<D: DataSource> DataSource for CommandBuilder<D>

Source§

fn len(&self) -> usize

Length of the serialized data
Source§

fn is_empty(&self) -> bool

Source§

impl<W: Writer, D: DataStream<W>> DataStream<W> for CommandBuilder<D>

Source§

fn to_writer(&self, writer: &mut W) -> Result<(), <W as Writer>::Error>

Serialize the data to a writer. Read more
Source§

impl<D: Debug> Debug for CommandBuilder<D>

Source§

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

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

impl<'a, D: PartialEq<&'a [u8]>> PartialEq<CommandBuilder<D>> for CommandView<'a>

Source§

fn eq(&self, other: &CommandBuilder<D>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, D: PartialEq<&'a [u8]>> PartialEq<CommandView<'a>> for CommandBuilder<D>

Source§

fn eq(&self, other: &CommandView<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<D: PartialEq> PartialEq for CommandBuilder<D>

Source§

fn eq(&self, other: &CommandBuilder<D>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<D: Eq> Eq for CommandBuilder<D>

Source§

impl<D> StructuralPartialEq for CommandBuilder<D>

Auto Trait Implementations§

§

impl<D> Freeze for CommandBuilder<D>
where D: Freeze,

§

impl<D> RefUnwindSafe for CommandBuilder<D>
where D: RefUnwindSafe,

§

impl<D> Send for CommandBuilder<D>
where D: Send,

§

impl<D> Sync for CommandBuilder<D>
where D: Sync,

§

impl<D> Unpin for CommandBuilder<D>
where D: Unpin,

§

impl<D> UnwindSafe for CommandBuilder<D>
where D: UnwindSafe,

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

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.