1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use super::*;
#[derive(Clone)]
pub struct UsbInterface {
pub interface_class: u8,
pub interface_subclass: u8,
pub interface_protocol: u8,
pub endpoints: Vec<UsbEndpoint>,
pub string_interface: u8,
pub class_specific_descriptor: Vec<u8>,
pub handler: Arc<Mutex<Box<dyn UsbInterfaceHandler + Send>>>,
}
pub trait UsbInterfaceHandler {
fn get_class_specific_descriptor(&self) -> Vec<u8>;
fn handle_urb(
&mut self,
interface: &UsbInterface,
ep: UsbEndpoint,
setup: SetupPacket,
req: &[u8],
) -> Result<Vec<u8>>;
fn as_any(&mut self) -> &mut dyn Any;
}