Skip to content

Commit

Permalink
Run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Jun 14, 2023
1 parent be54d6d commit a9685f5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
28 changes: 21 additions & 7 deletions components/apps/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ use apdu_dispatch::{
use core::marker::PhantomData;
use ctaphid_dispatch::app::App as CtaphidApp;
use trussed::{
backend::BackendId, client::ClientBuilder, platform::Syscall, ClientImplementation, Platform,
interrupt::InterruptFlag,
Service,
backend::BackendId, client::ClientBuilder, interrupt::InterruptFlag, platform::Syscall,
ClientImplementation, Platform, Service,
};

#[cfg(feature = "admin-app")]
Expand Down Expand Up @@ -114,7 +113,11 @@ pub struct Apps<R: Runner> {
impl<R: Runner> Apps<R> {
pub fn new(
runner: &R,
mut make_client: impl FnMut(&str, &'static [BackendId<Backend>], Option<&'static InterruptFlag>) -> Client<R>,
mut make_client: impl FnMut(
&str,
&'static [BackendId<Backend>],
Option<&'static InterruptFlag>,
) -> Client<R>,
data: Data<R>,
) -> Self {
let _ = (runner, &mut make_client);
Expand Down Expand Up @@ -220,7 +223,10 @@ impl<R: Runner> trussed_usbip::Apps<'static, Client<R>, Dispatch> for Apps<R> {
)
}

fn with_ctaphid_apps<T>(&mut self, f: impl FnOnce(&mut [&mut dyn CtaphidApp<'static>]) -> T) -> T {
fn with_ctaphid_apps<T>(
&mut self,
f: impl FnOnce(&mut [&mut dyn CtaphidApp<'static>]) -> T,
) -> T {
self.ctaphid_dispatch(f)
}

Expand All @@ -241,11 +247,19 @@ trait App<R: Runner>: Sized {

fn new(
runner: &R,
make_client: impl FnOnce(&str, &'static [BackendId<Backend>], Option<&'static InterruptFlag>) -> Client<R>,
make_client: impl FnOnce(
&str,
&'static [BackendId<Backend>],
Option<&'static InterruptFlag>,
) -> Client<R>,
data: Self::Data,
) -> Self {
let backends = Self::backends(runner);
Self::with_client(runner, make_client(Self::CLIENT_ID, backends, Self::interrupt()), data)
Self::with_client(
runner,
make_client(Self::CLIENT_ID, backends, Self::interrupt()),
data,
)
}

fn with_client(runner: &R, trussed: Client<R>, data: Self::Data) -> Self;
Expand Down
16 changes: 9 additions & 7 deletions runners/embedded/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ pub fn init_usb_nfc(
let config = <SocT as Soc>::INTERFACE_CONFIG;

use apdu_dispatch::interchanges::Channel as CcidChannel;
use trussed::interrupt::InterruptFlag;
use ref_swap::OptionRefSwap;
use ctaphid_dispatch::types::Channel as CtapChannel;
use ref_swap::OptionRefSwap;
use trussed::interrupt::InterruptFlag;
static CCID_CHANNEL: CcidChannel = Channel::new();
static NFC_CHANNEL: CcidChannel = Channel::new();
static CTAP_CHANNEL: CtapChannel = Channel::new();
Expand All @@ -191,7 +191,8 @@ pub fn init_usb_nfc(

/* initialize dispatchers */
let apdu_dispatch = apdu_dispatch::dispatch::ApduDispatch::new(ccid_rp, nfc_rp);
let ctaphid_dispatch = ctaphid_dispatch::dispatch::Dispatch::with_interrupt(ctaphid_rp, Some(&CTAP_INTERRUPT));
let ctaphid_dispatch =
ctaphid_dispatch::dispatch::Dispatch::with_interrupt(ctaphid_rp, Some(&CTAP_INTERRUPT));

/* populate requesters (if bus options are provided) */
let mut usb_classes = None;
Expand All @@ -201,10 +202,11 @@ pub fn init_usb_nfc(
let ccid = usbd_ccid::Ccid::new(usbbus, ccid_rq, Some(config.card_issuer));

/* Class #2: CTAPHID */
let ctaphid = usbd_ctaphid::CtapHid::with_interrupt(usbbus, ctaphid_rq, Some(&CTAP_INTERRUPT), 0u32)
.implements_ctap1()
.implements_ctap2()
.implements_wink();
let ctaphid =
usbd_ctaphid::CtapHid::with_interrupt(usbbus, ctaphid_rq, Some(&CTAP_INTERRUPT), 0u32)
.implements_ctap1()
.implements_ctap2()
.implements_wink();

/* Class #3: Serial */
let serial = usbd_serial::SerialPort::new(usbbus);
Expand Down
2 changes: 1 addition & 1 deletion runners/embedded/src/types/usbnfc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::types::Soc;

pub type CcidClass =
usbd_ccid::Ccid<'static, 'static, <SocT as Soc>::UsbBus, { apdu_dispatch::interchanges::SIZE }>;
pub type CtapHidClass = usbd_ctaphid::CtapHid<'static, 'static,'static, <SocT as Soc>::UsbBus>;
pub type CtapHidClass = usbd_ctaphid::CtapHid<'static, 'static, 'static, <SocT as Soc>::UsbBus>;
// pub type KeyboardClass = usbd_hid::hid_class::HIDClass<'static, <SocT as Soc>::UsbBus>;
pub type SerialClass = usbd_serial::SerialPort<'static, <SocT as Soc>::UsbBus>;

Expand Down

0 comments on commit a9685f5

Please sign in to comment.