Trait UsbContext

Source
pub trait UsbContext {
    // Required methods
    fn device_by_id_with_timeout(
        &self,
        usb_vid: u16,
        usb_pid: u16,
        usb_serial: Option<&str>,
        timeout: Duration,
    ) -> Result<Box<dyn UsbDevice>>;
    fn device_by_interface_with_timeout(
        &self,
        class: u8,
        subclass: u8,
        protocol: u8,
        usb_serial: Option<&str>,
        timeout: Duration,
    ) -> Result<Box<dyn UsbDevice>>;

    // Provided methods
    fn device_by_id(
        &self,
        usb_vid: u16,
        usb_pid: u16,
        usb_serial: Option<&str>,
    ) -> Result<Box<dyn UsbDevice>> { ... }
    fn device_by_interface(
        &self,
        class: u8,
        subclass: u8,
        protocol: u8,
        usb_serial: Option<&str>,
    ) -> Result<Box<dyn UsbDevice>> { ... }
}
Expand description

A trait which represents a USB context.

Required Methods§

Source

fn device_by_id_with_timeout( &self, usb_vid: u16, usb_pid: u16, usb_serial: Option<&str>, timeout: Duration, ) -> Result<Box<dyn UsbDevice>>

Find a device by VID:PID, and optionally disambiguate by serial number.

Source

fn device_by_interface_with_timeout( &self, class: u8, subclass: u8, protocol: u8, usb_serial: Option<&str>, timeout: Duration, ) -> Result<Box<dyn UsbDevice>>

Provided Methods§

Source

fn device_by_id( &self, usb_vid: u16, usb_pid: u16, usb_serial: Option<&str>, ) -> Result<Box<dyn UsbDevice>>

Find a device by VID:PID, and optionally disambiguate by serial number.

If no device matches, this function returns immediately and does not wait.

Source

fn device_by_interface( &self, class: u8, subclass: u8, protocol: u8, usb_serial: Option<&str>, ) -> Result<Box<dyn UsbDevice>>

Find a device with a specific interface, and optionally disambiguate by serial number.

If no device matches, this function returns immediately and does not wait.

Implementors§