Use arrayref for converting into ApduHeader

This commit is contained in:
Kamran Khan
2020-11-30 02:04:52 -08:00
parent d70dd24ffd
commit 5f5f72b6d1
3 changed files with 10 additions and 3 deletions

View File

@@ -58,8 +58,8 @@ pub struct ApduHeader {
p2: u8,
}
impl From<&[u8]> for ApduHeader {
fn from(header: &[u8]) -> Self {
impl From<&[u8; 4]> for ApduHeader {
fn from(header: &[u8; 4]) -> Self {
ApduHeader {
cla: header[0],
ins: header[1],
@@ -120,7 +120,7 @@ impl TryFrom<&[u8]> for APDU {
let (header, payload) = frame.split_at(APDU_HEADER_LEN);
let mut apdu = APDU {
header: header.into(),
header: array_ref!(header, 0, 4).into(),
lc: 0x00,
data: Vec::new(),
le: 0x00,

View File

@@ -18,3 +18,7 @@ extern crate alloc;
pub mod ctap;
pub mod embedded_flash;
#[macro_use]
extern crate arrayref;

View File

@@ -19,6 +19,9 @@ extern crate alloc;
extern crate core;
extern crate lang_items;
#[macro_use]
extern crate arrayref;
mod ctap;
pub mod embedded_flash;