pub trait UsbInterfaceHandler {
    // Required methods
    fn get_class_specific_descriptor(&self) -> Vec<u8>;
    fn handle_urb(
        &mut self,
        interface: &UsbInterface,
        ep: UsbEndpoint,
        transfer_buffer_length: u32,
        setup: SetupPacket,
        req: &[u8]
    ) -> Result<Vec<u8>>;
    fn as_any(&mut self) -> &mut dyn Any;
}
Expand description

A handler of a custom usb interface

Required Methods§

source

fn get_class_specific_descriptor(&self) -> Vec<u8>

Return the class specific descriptor which is inserted between interface descriptor and endpoint descriptor

source

fn handle_urb( &mut self, interface: &UsbInterface, ep: UsbEndpoint, transfer_buffer_length: u32, setup: SetupPacket, req: &[u8] ) -> Result<Vec<u8>>

Handle a URB(USB Request Block) targeting at this interface

Can be one of: control transfer to ep0 or other types of transfer to its endpoint. The resulting data should not exceed transfer_buffer_length.

source

fn as_any(&mut self) -> &mut dyn Any

Helper to downcast to actual struct

Please implement it as:

fn as_any(&mut self) -> &mut dyn Any {
    self
}

Implementors§