Struct iso7816::command::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>
impl<D: DataSource> CommandBuilder<D>
sourcepub fn new(
class: Class,
instruction: Instruction,
p1: u8,
p2: u8,
data: D,
le: impl Into<ExpectedLen>
) -> Self
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
sourcepub fn force_extended(self) -> Self
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.
pub fn data(&self) -> Dwhere
D: Copy,
sourcepub fn required_len(&self) -> usize
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
sourcepub fn serialize_into<W: Writer>(&self, writer: &mut W) -> Result<(), W::Error>where
D: DataStream<W>,
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]>
impl<'a> CommandBuilder<&'a [u8]>
sourcepub fn new_non_extended(
class: Class,
instruction: Instruction,
p1: u8,
p2: u8,
data: &'a [u8],
le: u16,
buffer_len: Option<usize>
) -> ChainedCommandIterator<'a> ⓘ
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
sourcepub fn should_split(&self, available_len: usize) -> Option<(Self, Self)>
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>
impl<D: Clone> Clone for CommandBuilder<D>
source§fn clone(&self) -> CommandBuilder<D>
fn clone(&self) -> CommandBuilder<D>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<D: DataSource> DataSource for CommandBuilder<D>
impl<D: DataSource> DataSource for CommandBuilder<D>
source§impl<W: Writer, D: DataStream<W>> DataStream<W> for CommandBuilder<D>
impl<W: Writer, D: DataStream<W>> DataStream<W> for CommandBuilder<D>
source§impl<D: Debug> Debug for CommandBuilder<D>
impl<D: Debug> Debug for CommandBuilder<D>
source§impl<'a, D: PartialEq<&'a [u8]>> PartialEq<CommandBuilder<D>> for CommandView<'a>
impl<'a, D: PartialEq<&'a [u8]>> PartialEq<CommandBuilder<D>> for CommandView<'a>
source§fn eq(&self, other: &CommandBuilder<D>) -> bool
fn eq(&self, other: &CommandBuilder<D>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, D: PartialEq<&'a [u8]>> PartialEq<CommandView<'a>> for CommandBuilder<D>
impl<'a, D: PartialEq<&'a [u8]>> PartialEq<CommandView<'a>> for CommandBuilder<D>
source§fn eq(&self, other: &CommandView<'a>) -> bool
fn eq(&self, other: &CommandView<'a>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<D: PartialEq> PartialEq for CommandBuilder<D>
impl<D: PartialEq> PartialEq for CommandBuilder<D>
source§fn eq(&self, other: &CommandBuilder<D>) -> bool
fn eq(&self, other: &CommandBuilder<D>) -> bool
self
and other
values to be equal, and is used
by ==
.