pub struct CommandApdu { /* private fields */ }Expand description
Owned encoded command; Debug is redacted and its buffer is wiped on drop.
Implementations§
Source§impl CommandApdu
impl CommandApdu
Sourcepub fn encode(
header: ApduHeader,
data: &[u8],
le: ExpectedLength,
encoding: ApduEncoding,
) -> Result<Self, Error>
pub fn encode( header: ApduHeader, data: &[u8], le: ExpectedLength, encoding: ApduEncoding, ) -> Result<Self, Error>
Encode one complete physical APDU, copying data into a protected buffer.
This does not split a logical command or check channel/device capabilities.
Use crate::operation::conversation for chaining and continuation.
§Errors
Returns ErrorKind::InvalidArgument when data or Le exceeds the encoding
range, or when Exact(0) is supplied.
§Examples
use canokey_protocol::{ApduEncoding, ApduHeader, CommandApdu, ExpectedLength};
let command = CommandApdu::encode(
ApduHeader::new(0, 0xcb, 0x3f, 0xff),
&[0x5c, 1, 0x7e], ExpectedLength::Exact(256), ApduEncoding::Short,
)?;
assert_eq!(command.as_bytes(), &[0, 0xcb, 0x3f, 0xff, 3, 0x5c, 1, 0x7e, 0]);Trait Implementations§
Source§impl Clone for CommandApdu
impl Clone for CommandApdu
Source§fn clone(&self) -> CommandApdu
fn clone(&self) -> CommandApdu
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CommandApdu
impl RefUnwindSafe for CommandApdu
impl Send for CommandApdu
impl Sync for CommandApdu
impl Unpin for CommandApdu
impl UnsafeUnpin for CommandApdu
impl UnwindSafe for CommandApdu
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more