mirror of
https://github.com/trussed-dev/usbd-ccid.git
synced 2026-06-20 04:16:20 -07:00
Get rid of heapless-bytes: use hopefully soon to be upstreamed heapless additions
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ where
|
||||
fn endpoint_out(&mut self, addr: EndpointAddress) {
|
||||
if addr != self.read.address() { return; }
|
||||
|
||||
let maybe_packet = RawPacket::try_from(
|
||||
let maybe_packet = RawPacket::try_read(
|
||||
|packet| self.read.read(packet));
|
||||
|
||||
// should we return an error message
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#![allow(non_camel_case_types)]
|
||||
use heapless_bytes::{
|
||||
use heapless::{
|
||||
consts,
|
||||
Unsigned as _
|
||||
};
|
||||
|
||||
+8
-8
@@ -1,4 +1,4 @@
|
||||
pub use heapless_bytes::{consts, ArrayLength, Bytes};
|
||||
pub use heapless::{consts, ArrayLength, ByteBuf};
|
||||
|
||||
const CONSTRUCTED: u8 = 1 << 5;
|
||||
// const CONTEXT_SPECIFIC: u8 = 2 << 6;
|
||||
@@ -40,7 +40,7 @@ type Result = core::result::Result<(), ()>;
|
||||
|
||||
/// DER writer
|
||||
#[derive(Debug)]
|
||||
pub struct Der<N>(Bytes<N>)
|
||||
pub struct Der<N>(ByteBuf<N>)
|
||||
where
|
||||
N: ArrayLength<u8>;
|
||||
|
||||
@@ -51,14 +51,14 @@ impl<N: ArrayLength<u8>> Default for Der<N> {
|
||||
}
|
||||
|
||||
impl<N: ArrayLength<u8>> core::ops::Deref for Der<N> {
|
||||
type Target = Bytes<N>;
|
||||
type Target = ByteBuf<N>;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: ArrayLength<u8>> core::ops::DerefMut for Der<N> {
|
||||
fn deref_mut(&mut self) -> &mut Bytes<N> {
|
||||
fn deref_mut(&mut self) -> &mut ByteBuf<N> {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ impl<N: ArrayLength<u8>> core::ops::DerefMut for Der<N> {
|
||||
impl<N: ArrayLength<u8>> Der<N> {
|
||||
/// Create a new `Der` structure that writes values to the given buffer
|
||||
pub fn new() -> Self {
|
||||
Der(Bytes::new())
|
||||
Der(ByteBuf::new())
|
||||
}
|
||||
|
||||
// // equivalent of method in std::io::Write
|
||||
@@ -75,7 +75,7 @@ impl<N: ArrayLength<u8>> Der<N> {
|
||||
// }
|
||||
|
||||
/// Return underlying buffer
|
||||
pub fn into_inner(self) -> Bytes<N> {
|
||||
pub fn into_inner(self) -> ByteBuf<N> {
|
||||
self.0
|
||||
}
|
||||
|
||||
@@ -234,8 +234,8 @@ mod test {
|
||||
];
|
||||
assert_eq!(der.len(), expected.len());
|
||||
assert_eq!(
|
||||
Bytes::<consts::U72>::try_from_slice(&der).unwrap(),
|
||||
Bytes::<consts::U72>::try_from_slice(&expected).unwrap(),
|
||||
ByteBuf::<consts::U72>::from_slice(&der).unwrap(),
|
||||
ByteBuf::<consts::U72>::from_slice(&expected).unwrap(),
|
||||
);
|
||||
// assert_eq!(&got[..32], &expected[..32]);
|
||||
// assert_eq!(&got[32..64], &expected[32..64]);
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ where
|
||||
panic!("short packet!");
|
||||
}
|
||||
|
||||
Err(PacketError::UnknownCommand(c)) => {
|
||||
Err(PacketError::UnknownCommand(_c)) => {
|
||||
// hprintln!("{:X?}", &p).ok();
|
||||
// panic!("unknown command byte 0x{:x}", c);
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
use core::convert::TryFrom;
|
||||
|
||||
use cortex_m_semihosting::hprintln;
|
||||
use heapless_bytes::consts;
|
||||
use heapless::consts;
|
||||
|
||||
use crate::{
|
||||
der::Der,
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// use cortex_m_semihosting::hprintln;
|
||||
use heapless_bytes::Bytes;
|
||||
use heapless::ByteBuf;
|
||||
|
||||
use crate::constants::*;
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::constants::*;
|
||||
pub mod packet;
|
||||
pub mod tlv;
|
||||
|
||||
pub type MessageBuffer = Bytes<MAX_MSG_LENGTH_TYPE>;
|
||||
pub type MessageBuffer = ByteBuf<MAX_MSG_LENGTH_TYPE>;
|
||||
|
||||
interchange::interchange! {
|
||||
ApduInterchange: (iso7816::Command, iso7816::Response)
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ interchange::interchange! {
|
||||
// p2: apdu.p2(),
|
||||
// lc: apdu.lc(),
|
||||
// le: apdu.le(),
|
||||
// data: MessageBuffer::try_from_slice(apdu.data()).unwrap(),
|
||||
// data: MessageBuffer::from_slice(apdu.data()).unwrap(),
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ use core::convert::TryInto;
|
||||
use crate::constants::*;
|
||||
|
||||
|
||||
pub type RawPacket = heapless_bytes::Bytes<PACKET_SIZE_TYPE>;
|
||||
pub type ExtPacket = heapless_bytes::Bytes<EXT_PACKET_SIZE_TYPE>;
|
||||
pub type RawPacket = heapless::ByteBuf<PACKET_SIZE_TYPE>;
|
||||
pub type ExtPacket = heapless::ByteBuf<EXT_PACKET_SIZE_TYPE>;
|
||||
|
||||
pub trait RawPacketExt {
|
||||
fn packet_len(&self) -> usize;
|
||||
|
||||
Reference in New Issue
Block a user