Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ usb-device = { version = "0.2.7", default-features = false }
usbip-device = "0.1.5"

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

# ccid
apdu-dispatch = { version = "0.3", optional = true }
Expand Down
12 changes: 4 additions & 8 deletions examples/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

use std::path::PathBuf;

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

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

#[cfg(feature = "ctaphid")]
fn with_ctaphid_apps<T>(
fn with_ctaphid_apps<T, const N: usize>(
&mut self,
f: impl FnOnce(
&mut [&mut dyn ctaphid_dispatch::app::App<'a, { ctaphid_dispatch::MESSAGE_SIZE }>],
) -> T,
f: impl FnOnce(&mut [&mut dyn ctaphid_dispatch::app::App<'a, N>]) -> T,
) -> T {
f(&mut [&mut self.dummy])
}

#[cfg(feature = "ccid")]
fn with_ccid_apps<T>(
fn with_ccid_apps<T, const N: usize>(
&mut self,
f: impl FnOnce(&mut [&mut dyn apdu_dispatch::app::App<ApduCommandSize>]) -> T,
f: impl FnOnce(&mut [&mut dyn apdu_dispatch::app::App<N>]) -> T,
) -> T {
f(&mut [])
}
Expand Down
12 changes: 6 additions & 6 deletions src/ctaphid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use usbd_ctaphid::{types::Status, CtapHid};

use super::{Timeout, IS_WAITING};

pub fn setup<'bus, 'pipe, 'interrupt, B: UsbBus>(
pub fn setup<'bus, 'pipe, 'interrupt, B: UsbBus, const N: usize>(
bus_allocator: &'bus UsbBusAllocator<B>,
interchange: &'pipe ctaphid_dispatch::Channel,
interchange: &'pipe ctaphid_dispatch::Channel<N>,
) -> (
CtapHid<'bus, 'pipe, 'interrupt, B>,
Dispatch<'pipe, 'interrupt>,
CtapHid<'bus, 'pipe, 'interrupt, B, N>,
Dispatch<'pipe, 'interrupt, N>,
) {
let (ctaphid_rq, ctaphid_rp) = interchange.split().unwrap();
let ctaphid = CtapHid::new(bus_allocator, ctaphid_rq, 0u32)
Expand All @@ -25,8 +25,8 @@ pub fn setup<'bus, 'pipe, 'interrupt, B: UsbBus>(
(ctaphid, ctaphid_dispatch)
}

pub fn keepalive<B: UsbBus>(
ctaphid: &mut CtapHid<'_, '_, '_, B>,
pub fn keepalive<B: UsbBus, const N: usize>(
ctaphid: &mut CtapHid<'_, '_, '_, B, N>,
timeout: &mut Timeout,
epoch: Instant,
) {
Expand Down
18 changes: 8 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,15 @@ pub trait Apps<'interrupt, D: Dispatch> {
) -> Self;

#[cfg(feature = "ctaphid")]
fn with_ctaphid_apps<T>(
fn with_ctaphid_apps<T, const N: usize>(
&mut self,
f: impl FnOnce(
&mut [&mut dyn ctaphid_dispatch::app::App<
'interrupt,
{ ctaphid_dispatch::MESSAGE_SIZE },
>],
) -> T,
f: impl FnOnce(&mut [&mut dyn ctaphid_dispatch::app::App<'interrupt, N>]) -> T,
) -> T;

#[cfg(feature = "ccid")]
fn with_ccid_apps<T>(
fn with_ccid_apps<T, const N: usize>(
&mut self,
f: impl FnOnce(&mut [&mut dyn apdu_dispatch::app::App<7609>]) -> T,
f: impl FnOnce(&mut [&mut dyn apdu_dispatch::app::App<N>]) -> T,
) -> T;
}

Expand Down Expand Up @@ -163,7 +158,10 @@ where
#[cfg(feature = "ctaphid")]
let ctap_channel = ctaphid_dispatch::Channel::new();
#[cfg(feature = "ctaphid")]
let (mut ctaphid, mut ctaphid_dispatch) = ctaphid::setup(&bus_allocator, &ctap_channel);
let (mut ctaphid, mut ctaphid_dispatch) = ctaphid::setup::<
_,
{ ctaphid_dispatch::DEFAULT_MESSAGE_SIZE },
>(&bus_allocator, &ctap_channel);

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