Skip to content

Commit edc5d69

Browse files
Update to heapless 0.9
1 parent dd8d252 commit edc5d69

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ license = "Apache-2.0 OR MIT"
99
repository = "https://github.com/solokeys/ctaphid-dispatch"
1010

1111
[workspace.dependencies]
12-
heapless-bytes = "0.3"
12+
heapless-bytes = "0.5"
1313
trussed-core = "0.1.0"
1414

1515
[patch.crates-io]
1616
ctaphid-app.path = "app"
17+
trussed-core = { git = "https://github.com/trussed-dev/trussed.git", rev = "1e7b09a983dc8ae64a7ad8401ce541a9a77e5939"}

app/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![no_std]
22

3-
use heapless_bytes::Bytes;
3+
use heapless_bytes::BytesView;
44
use trussed_core::InterruptFlag;
55

66
mod command;
@@ -10,7 +10,7 @@ pub use command::{Command, VendorCommand};
1010
/// trait interface for a CTAPHID application.
1111
/// The application chooses which commands to register to, and will be called upon
1212
/// when the commands are received in the CTAPHID layer. Only one application can be registered to a particular command.
13-
pub trait App<'interrupt, const N: usize> {
13+
pub trait App<'interrupt> {
1414
/// Get access to the app interrupter
1515
fn interrupt(&self) -> Option<&'interrupt InterruptFlag> {
1616
None
@@ -27,7 +27,7 @@ pub trait App<'interrupt, const N: usize> {
2727
&mut self,
2828
command: Command,
2929
request: &[u8],
30-
response: &mut Bytes<N>,
30+
response: &mut BytesView,
3131
) -> Result<(), Error>;
3232
}
3333

dispatch/src/dispatch.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::sync::atomic::Ordering;
33
use crate::types::{InterchangeResponse, Responder};
44

55
use ctaphid_app::{App, Command, Error};
6-
use heapless_bytes::Bytes;
6+
use heapless_bytes::{Bytes, BytesView};
77
use ref_swap::OptionRefSwap;
88
use trussed_core::InterruptFlag;
99

@@ -34,8 +34,8 @@ impl<'pipe, 'interrupt, const N: usize> Dispatch<'pipe, 'interrupt, N> {
3434

3535
fn find_app<'a, 'b>(
3636
command: Command,
37-
apps: &'a mut [&'b mut dyn App<'interrupt, N>],
38-
) -> Option<&'a mut &'b mut dyn App<'interrupt, N>> {
37+
apps: &'a mut [&'b mut dyn App<'interrupt>],
38+
) -> Option<&'a mut &'b mut dyn App<'interrupt>> {
3939
apps.iter_mut()
4040
.find(|app| app.commands().contains(&command))
4141
}
@@ -75,7 +75,7 @@ impl<'pipe, 'interrupt, const N: usize> Dispatch<'pipe, 'interrupt, N> {
7575
}
7676

7777
#[inline(never)]
78-
fn call_app(&mut self, app: &mut dyn App<'interrupt, N>, command: Command, request: &Bytes<N>) {
78+
fn call_app(&mut self, app: &mut dyn App<'interrupt>, command: Command, request: &BytesView) {
7979
let response_buffer = self
8080
.responder
8181
.response_mut()
@@ -106,9 +106,9 @@ impl<'pipe, 'interrupt, const N: usize> Dispatch<'pipe, 'interrupt, N> {
106106
}
107107

108108
#[inline(never)]
109-
pub fn poll(&mut self, apps: &mut [&mut dyn App<'interrupt, N>]) -> bool {
109+
pub fn poll(&mut self, apps: &mut [&mut dyn App<'interrupt>]) -> bool {
110110
// We could call take_request directly, but for some reason this doubles stack usage.
111-
let mut message_buffer = Bytes::new();
111+
let mut message_buffer = Bytes::<1024>::new();
112112
if let Ok((command, message)) = self.responder.request() {
113113
// info_now!("cmd: {}", u8::from(command));
114114
// info_now!("cmd: {:?}", command);

0 commit comments

Comments
 (0)