Trait UsbDevice

Source
pub trait UsbDevice {
Show 27 methods // Required methods fn get_vendor_id(&self) -> u16; fn get_product_id(&self) -> u16; fn get_serial_number(&self) -> Option<&str>; fn get_parent(&self) -> Result<Box<dyn UsbDevice>>; fn set_active_configuration(&self, config: u8) -> Result<()>; fn claim_interface(&self, iface: u8) -> Result<()>; fn release_interface(&self, iface: u8) -> Result<()>; fn set_alternate_setting(&self, iface: u8, setting: u8) -> Result<()>; fn kernel_driver_active(&self, iface: u8) -> Result<bool>; fn detach_kernel_driver(&self, iface: u8) -> Result<()>; fn attach_kernel_driver(&self, iface: u8) -> Result<()>; fn device_descriptor(&self) -> Device<'_>; fn active_configuration(&self) -> Result<Configuration<'_>>; fn bus_number(&self) -> u8; fn address(&self) -> u8; fn port_numbers(&self) -> Result<Vec<u8>>; fn read_string_descriptor_ascii(&self, idx: u8) -> Result<String>; fn reset(&self) -> Result<()>; fn get_timeout(&self) -> Duration; fn write_control_timeout( &self, request_type: u8, request: u8, value: u16, index: u16, buf: &[u8], timeout: Duration, ) -> Result<usize>; fn read_control_timeout( &self, request_type: u8, request: u8, value: u16, index: u16, buf: &mut [u8], timeout: Duration, ) -> Result<usize>; fn read_bulk_timeout( &self, endpoint: u8, data: &mut [u8], timeout: Duration, ) -> Result<usize>; fn write_bulk_timeout( &self, endpoint: u8, data: &[u8], timeout: Duration, ) -> Result<usize>; // Provided methods fn write_control( &self, request_type: u8, request: u8, value: u16, index: u16, buf: &[u8], ) -> Result<usize> { ... } fn read_control( &self, request_type: u8, request: u8, value: u16, index: u16, buf: &mut [u8], ) -> Result<usize> { ... } fn read_bulk(&self, endpoint: u8, data: &mut [u8]) -> Result<usize> { ... } fn write_bulk(&self, endpoint: u8, data: &[u8]) -> Result<usize> { ... }
}
Expand description

A trait which represents a USB device.

Required Methods§

Source

fn get_vendor_id(&self) -> u16

Return the VID of the device.

Source

fn get_product_id(&self) -> u16

Return the PID of the device.

Source

fn get_serial_number(&self) -> Option<&str>

Gets the serial number of the device.

Source

fn get_parent(&self) -> Result<Box<dyn UsbDevice>>

Try to get the parent of this device (or None if root).

Source

fn set_active_configuration(&self, config: u8) -> Result<()>

Set the active configuration.

Source

fn claim_interface(&self, iface: u8) -> Result<()>

Claim an interface for use with the kernel.

Source

fn release_interface(&self, iface: u8) -> Result<()>

Release a previously claimed interface to the kernel.

Source

fn set_alternate_setting(&self, iface: u8, setting: u8) -> Result<()>

Set an interface alternate setting.

Source

fn kernel_driver_active(&self, iface: u8) -> Result<bool>

Check whether a kernel driver currentl controls the device.

Source

fn detach_kernel_driver(&self, iface: u8) -> Result<()>

Detach the kernel driver from the device.

Source

fn attach_kernel_driver(&self, iface: u8) -> Result<()>

Attach the kernel driver to the device.

Source

fn device_descriptor(&self) -> Device<'_>

Return the device’s descriptor.

Source

fn active_configuration(&self) -> Result<Configuration<'_>>

Return the currently active configuration’s descriptor.

Source

fn bus_number(&self) -> u8

Return the device’s bus number.

Source

fn address(&self) -> u8

Return the device’s address.

Source

fn port_numbers(&self) -> Result<Vec<u8>>

Return the sequence of port numbers from the root down to the device.

Source

fn read_string_descriptor_ascii(&self, idx: u8) -> Result<String>

Return a string descriptor in ASCII.

Source

fn reset(&self) -> Result<()>

Reset the device.

Note that this UsbDevice handle will most likely become invalid after resetting the device and a new one has to be obtained.

Source

fn get_timeout(&self) -> Duration

Get the default timeout for operations.

Source

fn write_control_timeout( &self, request_type: u8, request: u8, value: u16, index: u16, buf: &[u8], timeout: Duration, ) -> Result<usize>

Issue a USB control request with optional host-to-device data.

Source

fn read_control_timeout( &self, request_type: u8, request: u8, value: u16, index: u16, buf: &mut [u8], timeout: Duration, ) -> Result<usize>

Issue a USB control request with optional device-to-host data.

Source

fn read_bulk_timeout( &self, endpoint: u8, data: &mut [u8], timeout: Duration, ) -> Result<usize>

Read bulk data bytes to given USB endpoint.

Source

fn write_bulk_timeout( &self, endpoint: u8, data: &[u8], timeout: Duration, ) -> Result<usize>

Write bulk data bytes to given USB endpoint.

Provided Methods§

Source

fn write_control( &self, request_type: u8, request: u8, value: u16, index: u16, buf: &[u8], ) -> Result<usize>

Issue a USB control request with optional host-to-device data.

This function uses the default timeout set up by the context.

Source

fn read_control( &self, request_type: u8, request: u8, value: u16, index: u16, buf: &mut [u8], ) -> Result<usize>

Issue a USB control request with optional device-to-host data.

This function uses the default timeout set up by the context.

Source

fn read_bulk(&self, endpoint: u8, data: &mut [u8]) -> Result<usize>

Read bulk data bytes to given USB endpoint.

This function uses the default timeout set up by the context.

Source

fn write_bulk(&self, endpoint: u8, data: &[u8]) -> Result<usize>

Write bulk data bytes to given USB endpoint.

This function uses the default timeout set up by the context.

Implementors§