Skip to content

Commit fa8b446

Browse files
Update to heapless 0.9
1 parent 2001761 commit fa8b446

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ 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]

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/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ default = []
2121
std = ["delog/std"]
2222

2323
log-all = []
24+
log-trace = []
2425
log-none = []
2526
log-info = []
2627
log-debug = []

dispatch/src/dispatch.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::sync::atomic::Ordering;
22

3-
use crate::types::{InterchangeResponse, Message, Responder, MESSAGE_SIZE};
3+
use crate::types::{InterchangeResponse, Message, Responder};
44

55
use ctaphid_app::{App, Command, Error};
66
use ref_swap::OptionRefSwap;
@@ -33,8 +33,8 @@ impl<'pipe, 'interrupt> Dispatch<'pipe, 'interrupt> {
3333

3434
fn find_app<'a, 'b>(
3535
command: Command,
36-
apps: &'a mut [&'b mut dyn App<'interrupt, MESSAGE_SIZE>],
37-
) -> Option<&'a mut &'b mut dyn App<'interrupt, MESSAGE_SIZE>> {
36+
apps: &'a mut [&'b mut dyn App<'interrupt>],
37+
) -> Option<&'a mut &'b mut dyn App<'interrupt>> {
3838
apps.iter_mut()
3939
.find(|app| app.commands().contains(&command))
4040
}
@@ -73,12 +73,7 @@ impl<'pipe, 'interrupt> Dispatch<'pipe, 'interrupt> {
7373
}
7474

7575
#[inline(never)]
76-
fn call_app(
77-
&mut self,
78-
app: &mut dyn App<'interrupt, MESSAGE_SIZE>,
79-
command: Command,
80-
request: &Message,
81-
) {
76+
fn call_app(&mut self, app: &mut dyn App<'interrupt>, command: Command, request: &Message) {
8277
let response_buffer = self
8378
.responder
8479
.response_mut()
@@ -109,7 +104,7 @@ impl<'pipe, 'interrupt> Dispatch<'pipe, 'interrupt> {
109104
}
110105

111106
#[inline(never)]
112-
pub fn poll(&mut self, apps: &mut [&mut dyn App<'interrupt, MESSAGE_SIZE>]) -> bool {
107+
pub fn poll(&mut self, apps: &mut [&mut dyn App<'interrupt>]) -> bool {
113108
// We could call take_request directly, but for some reason this doubles stack usage.
114109
let mut message_buffer = Message::new();
115110
if let Ok((command, message)) = self.responder.request() {

0 commit comments

Comments
 (0)