Skip to content

Commit 5046744

Browse files
Update to ctaphid-dispatch v0.3.0 and usbd-ctaphid v0.3.0
1 parent 2a002fd commit 5046744

5 files changed

Lines changed: 24 additions & 30 deletions

File tree

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ usb-device = { version = "0.2.7", default-features = false }
1515
usbip-device = "0.1.5"
1616

1717
# ctaphid
18-
ctaphid-dispatch = { version = "0.2", features = ["log-all"], optional = true }
19-
usbd-ctaphid = { version = "0.2", features = ["log-all"], optional = true }
18+
ctaphid-dispatch = { version = "0.3", features = ["log-all"], optional = true }
19+
usbd-ctaphid = { version = "0.3", features = ["log-all"], optional = true }
2020

2121
# ccid
2222
apdu-dispatch = { version = "0.3", optional = true }

examples/dummy.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
1010
use std::path::PathBuf;
1111

12-
#[cfg(feature = "ccid")]
13-
use apdu_dispatch::command::SIZE as ApduCommandSize;
1412
#[cfg(feature = "ctaphid")]
1513
use ctaphid_dispatch::app::{Command, Error, VendorCommand};
1614

@@ -113,19 +111,17 @@ impl<'a> trussed_usbip::Apps<'a, CoreOnly> for Apps<trussed_usbip::Client<CoreOn
113111
}
114112

115113
#[cfg(feature = "ctaphid")]
116-
fn with_ctaphid_apps<T>(
114+
fn with_ctaphid_apps<T, const N: usize>(
117115
&mut self,
118-
f: impl FnOnce(
119-
&mut [&mut dyn ctaphid_dispatch::app::App<'a, { ctaphid_dispatch::MESSAGE_SIZE }>],
120-
) -> T,
116+
f: impl FnOnce(&mut [&mut dyn ctaphid_dispatch::app::App<'a, N>]) -> T,
121117
) -> T {
122118
f(&mut [&mut self.dummy])
123119
}
124120

125121
#[cfg(feature = "ccid")]
126-
fn with_ccid_apps<T>(
122+
fn with_ccid_apps<T, const N: usize>(
127123
&mut self,
128-
f: impl FnOnce(&mut [&mut dyn apdu_dispatch::app::App<ApduCommandSize>]) -> T,
124+
f: impl FnOnce(&mut [&mut dyn apdu_dispatch::app::App<N>]) -> T,
129125
) -> T {
130126
f(&mut [])
131127
}

src/ctaphid.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ use usbd_ctaphid::{types::Status, CtapHid};
99

1010
use super::{Timeout, IS_WAITING};
1111

12-
pub fn setup<'bus, 'pipe, 'interrupt, B: UsbBus>(
12+
pub fn setup<'bus, 'pipe, 'interrupt, B: UsbBus, const N: usize>(
1313
bus_allocator: &'bus UsbBusAllocator<B>,
14-
interchange: &'pipe ctaphid_dispatch::Channel,
14+
interchange: &'pipe ctaphid_dispatch::Channel<N>,
1515
) -> (
16-
CtapHid<'bus, 'pipe, 'interrupt, B>,
17-
Dispatch<'pipe, 'interrupt>,
16+
CtapHid<'bus, 'pipe, 'interrupt, B, N>,
17+
Dispatch<'pipe, 'interrupt, N>,
1818
) {
1919
let (ctaphid_rq, ctaphid_rp) = interchange.split().unwrap();
2020
let ctaphid = CtapHid::new(bus_allocator, ctaphid_rq, 0u32)
@@ -25,8 +25,8 @@ pub fn setup<'bus, 'pipe, 'interrupt, B: UsbBus>(
2525
(ctaphid, ctaphid_dispatch)
2626
}
2727

28-
pub fn keepalive<B: UsbBus>(
29-
ctaphid: &mut CtapHid<'_, '_, '_, B>,
28+
pub fn keepalive<B: UsbBus, const N: usize>(
29+
ctaphid: &mut CtapHid<'_, '_, '_, B, N>,
3030
timeout: &mut Timeout,
3131
epoch: Instant,
3232
) {

src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,15 @@ pub trait Apps<'interrupt, D: Dispatch> {
6666
) -> Self;
6767

6868
#[cfg(feature = "ctaphid")]
69-
fn with_ctaphid_apps<T>(
69+
fn with_ctaphid_apps<T, const N: usize>(
7070
&mut self,
71-
f: impl FnOnce(
72-
&mut [&mut dyn ctaphid_dispatch::app::App<
73-
'interrupt,
74-
{ ctaphid_dispatch::MESSAGE_SIZE },
75-
>],
76-
) -> T,
71+
f: impl FnOnce(&mut [&mut dyn ctaphid_dispatch::app::App<'interrupt, N>]) -> T,
7772
) -> T;
7873

7974
#[cfg(feature = "ccid")]
80-
fn with_ccid_apps<T>(
75+
fn with_ccid_apps<T, const N: usize>(
8176
&mut self,
82-
f: impl FnOnce(&mut [&mut dyn apdu_dispatch::app::App<7609>]) -> T,
77+
f: impl FnOnce(&mut [&mut dyn apdu_dispatch::app::App<N>]) -> T,
8378
) -> T;
8479
}
8580

@@ -163,7 +158,10 @@ where
163158
#[cfg(feature = "ctaphid")]
164159
let ctap_channel = ctaphid_dispatch::Channel::new();
165160
#[cfg(feature = "ctaphid")]
166-
let (mut ctaphid, mut ctaphid_dispatch) = ctaphid::setup(&bus_allocator, &ctap_channel);
161+
let (mut ctaphid, mut ctaphid_dispatch) = ctaphid::setup::<
162+
_,
163+
{ ctaphid_dispatch::DEFAULT_MESSAGE_SIZE },
164+
>(&bus_allocator, &ctap_channel);
167165

168166
#[cfg(feature = "ccid")]
169167
let (contact, contactless) = Default::default();

0 commit comments

Comments
 (0)