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

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<'a, D: PartialEq<&'a [u8]>> PartialEq<CommandView<'a>> for CommandBuilder<D>

source§

fn eq(&self, other: &CommandView<'a>) -> 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<D: PartialEq> PartialEq for CommandBuilder<D>

source§

fn eq(&self, other: &CommandBuilder<D>) -> 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<D: Eq> Eq for CommandBuilder<D>

source§

impl<D> StructuralEq for CommandBuilder<D>

source§

impl<D> StructuralPartialEq for CommandBuilder<D>

Auto Trait Implementations§

§

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

§

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.