UsbDevice

Struct UsbDevice 

Source
pub struct UsbDevice {
Show 18 fields pub configurations: Vec<UsbConfiguration>, pub configuration: Option<UsbConfiguration>, pub device_class: u8, pub device_subclass: u8, pub device_protocol: u8, pub device_version_major: u8, pub device_version_minor: u8, pub device_version_subminor: u8, pub manufacturer_name: Option<String>, pub product_id: u16, pub product_name: Option<String>, pub serial_number: Option<String>, pub usb_version_major: u8, pub usb_version_minor: u8, pub usb_version_subminor: u8, pub vendor_id: u16, pub opened: bool, pub url: Option<String>, /* private fields */
}
Expand description

Represents a UsbDevice. Only way you can obtain one is through Context::devices https://wicg.github.io/webusb/#device-usage

Fields§

§configurations: Vec<UsbConfiguration>

List of configurations supported by the device. Populated from the configuration descriptor. configurations.len() SHALL be equal to the bNumConfigurations field of the device descriptor.

§configuration: Option<UsbConfiguration>

Represents the currently selected configuration. One of the elements of self.configurations. None, if the device is not configured.

§device_class: u8

bDeviceClass value of the device descriptor.

§device_subclass: u8

bDeviceSubClass value of the device descriptor.

§device_protocol: u8

bDeviceProtocol value of the device descriptor.

§device_version_major: u8

The major version declared by bcdDevice field such that bcdDevice 0xJJMN represents major version JJ.

§device_version_minor: u8

The minor version declared by bcdDevice field such that bcdDevice 0xJJMN represents minor version M.

§device_version_subminor: u8

The subminor version declared by bcdDevice field such that bcdDevice 0xJJMN represents subminor version N.

§manufacturer_name: Option<String>

Optional property of the string descriptor. Indexed by the iManufacturer field of device descriptor.

§product_id: u16

idProduct field of the device descriptor.

§product_name: Option<String>

Optional property of the string descriptor. Indexed by the iProduct field of device descriptor.

§serial_number: Option<String>

Optional property of the string descriptor. None, if the iSerialNumber field of device descriptor is 0.

§usb_version_major: u8

The major version declared by bcdUSB field such that bcdUSB 0xJJMN represents major version JJ.

§usb_version_minor: u8

The minor version declared by bcdUSB field such that bcdUSB 0xJJMN represents minor version M.

§usb_version_subminor: u8

The subminor version declared by bcdUSB field such that bcdUSB 0xJJMN represents subminor version N.

§vendor_id: u16

idVendor field of the device descriptor. https://wicg.github.io/webusb/#vendor-id

§opened: bool

If true, the underlying device handle is owned by this object.

§url: Option<String>

WEBUSB_URL value of the WebUSB Platform Capability Descriptor.

Implementations§

Source§

impl UsbDevice

Source

pub fn isochronous_transfer_in(&mut self)

Source

pub fn isochronous_transfer_out(&mut self)

Source

pub fn open(&mut self) -> Result<()>

Source

pub fn close(&mut self) -> Result<()>

Source

pub fn select_configuration(&mut self, configuration_value: u8) -> Result<()>

configuration_value is the bConfigurationValue of the device configuration.

Source

pub fn claim_interface(&mut self, interface_number: u8) -> Result<()>

Source

pub fn release_interface(&mut self, interface_number: u8) -> Result<()>

Source

pub fn select_alternate_interface( &mut self, interface_number: u8, alternate_setting: u8, ) -> Result<()>

Source

pub fn control_transfer_in( &mut self, setup: UsbControlTransferParameters, length: usize, ) -> Result<Vec<u8>>

Source

pub fn control_transfer_out( &mut self, setup: UsbControlTransferParameters, data: &[u8], ) -> Result<usize>

Source

pub fn clear_halt( &mut self, direction: Direction, endpoint_number: u8, ) -> Result<()>

Source

pub fn transfer_in( &mut self, endpoint_number: u8, length: usize, ) -> Result<Vec<u8>>

Source

pub fn transfer_out( &mut self, endpoint_number: u8, data: &[u8], ) -> Result<usize>

Source

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

Trait Implementations§

Source§

impl TryFrom<Device<Context>> for UsbDevice

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(device: Device<Context>) -> Result<UsbDevice>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.