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 more