mirror of
https://github.com/trussed-dev/usbd-ctaphid.git
synced 2026-06-20 04:16:20 -07:00
Add pipe lifetime
This commit is contained in:
committed by
Markus Meissner
parent
2580bc6944
commit
e415b176c8
+6
-6
@@ -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<Bus>,
|
||||
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<Target = Pipe> 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<Bus> for CtapHid<'alloc, Bus>
|
||||
impl<'alloc, 'pipe, Bus> UsbClass<Bus> for CtapHid<'alloc, 'pipe, Bus>
|
||||
where
|
||||
Bus: UsbBus,
|
||||
{
|
||||
|
||||
+4
-4
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user