diff --git a/src/class.rs b/src/class.rs index d6041b7..61439de 100644 --- a/src/class.rs +++ b/src/class.rs @@ -20,18 +20,18 @@ use usb_device::{ }; /// Packet-level implementation of the CTAPHID protocol. -pub struct CtapHid<'alloc, Bus: UsbBus> { +pub struct CtapHid<'alloc, 'pipe, Bus: UsbBus> { interface: InterfaceNumber, - pipe: Pipe<'alloc, Bus>, + pipe: Pipe<'alloc, 'pipe, Bus>, } -impl<'alloc, Bus> CtapHid<'alloc, Bus> +impl<'alloc, 'pipe, Bus> CtapHid<'alloc, 'pipe, Bus> where Bus: UsbBus, { pub fn new( allocate: &'alloc UsbBusAllocator, - interchange: Requester<'static>, + interchange: Requester<'pipe>, initial_milliseconds: u32, ) -> Self { // 64 bytes, interrupt endpoint polled every 5 milliseconds @@ -78,7 +78,7 @@ where } // implement DerefMut instead - pub fn pipe(&mut self) -> &mut Pipe<'alloc, Bus> { + pub fn pipe(&mut self) -> &mut Pipe<'alloc, 'pipe, Bus> { &mut self.pipe } @@ -184,7 +184,7 @@ pub enum ClassRequests { SetProtocol = 0xB, } -impl<'alloc, Bus> UsbClass for CtapHid<'alloc, Bus> +impl<'alloc, 'pipe, Bus> UsbClass for CtapHid<'alloc, 'pipe, Bus> where Bus: UsbBus, { diff --git a/src/pipe.rs b/src/pipe.rs index 0268551..08e772f 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -121,12 +121,12 @@ pub enum State { Sending((Response, MessageState)), } -pub struct Pipe<'alloc, Bus: UsbBus> { +pub struct Pipe<'alloc, 'pipe, Bus: UsbBus> { read_endpoint: EndpointOut<'alloc, Bus>, write_endpoint: EndpointIn<'alloc, Bus>, state: State, - interchange: Requester<'static>, + interchange: Requester<'pipe>, // shared between requests and responses, due to size buffer: [u8; MESSAGE_SIZE], @@ -149,7 +149,7 @@ pub struct Pipe<'alloc, Bus: UsbBus> { pub(crate) version: crate::Version, } -impl<'alloc, Bus: UsbBus> Pipe<'alloc, Bus> { +impl<'alloc, 'pipe, Bus: UsbBus> Pipe<'alloc, 'pipe, Bus> { // pub fn borrow_mut_authenticator(&mut self) -> &mut Authenticator { // &mut self.authenticator // } @@ -157,7 +157,7 @@ impl<'alloc, Bus: UsbBus> Pipe<'alloc, Bus> { pub(crate) fn new( read_endpoint: EndpointOut<'alloc, Bus>, write_endpoint: EndpointIn<'alloc, Bus>, - interchange: Requester<'static>, + interchange: Requester<'pipe>, initial_milliseconds: u32, ) -> Self { Self {