Struct DeviceInfo

Source
pub struct DeviceInfo { /* private fields */ }
Expand description

Information about a device that can be obtained without opening it.

Found in the results of crate::list_devices.

§Platform-specific notes

  • Some fields are platform-specific
    • Linux: sysfs_path
    • Windows: instance_id, parent_instance_id, port_number, driver
    • macOS: registry_id, location_id

Implementations§

Source§

impl DeviceInfo

Source

pub fn id(&self) -> DeviceId

Opaque identifier for the device.

Source

pub fn sysfs_path(&self) -> &Path

(Linux-only) Sysfs path for the device.

Source

pub fn busnum(&self) -> u8

(Linux-only) Bus number.

On Linux, the bus_id is an integer and this provides the value as u8.

Source

pub fn port_chain(&self) -> &[u8]

Path of port numbers identifying the port where the device is connected.

Together with the bus ID, it identifies a physical port. The path is expected to remain stable across device insertions or reboots.

Since USB SuperSpeed is a separate topology from USB 2.0 speeds, a physical port may be identified differently depending on speed.

Source

pub fn bus_id(&self) -> &str

Identifier for the bus / host controller where the device is connected.

Source

pub fn device_address(&self) -> u8

Number identifying the device within the bus.

Source

pub fn vendor_id(&self) -> u16

The 16-bit number identifying the device’s vendor, from the idVendor device descriptor field.

Source

pub fn product_id(&self) -> u16

The 16-bit number identifying the product, from the idProduct device descriptor field.

Source

pub fn device_version(&self) -> u16

The device version, normally encoded as BCD, from the bcdDevice device descriptor field.

Source

pub fn usb_version(&self) -> u16

Encoded version of the USB specification, from the bcdUSB device descriptor field.

Source

pub fn class(&self) -> u8

Code identifying the standard device class, from the bDeviceClass device descriptor field.

0x00: specified at the interface level.
0xFF: vendor-defined.

Source

pub fn subclass(&self) -> u8

Standard subclass, from the bDeviceSubClass device descriptor field.

Source

pub fn protocol(&self) -> u8

Standard protocol, from the bDeviceProtocol device descriptor field.

Source

pub fn max_packet_size_0(&self) -> u8

Maximum packet size for endpoint zero.

Source

pub fn speed(&self) -> Option<Speed>

Connection speed

Source

pub fn manufacturer_string(&self) -> Option<&str>

Manufacturer string, if available without device IO.

§Platform-specific notes
  • Windows: Windows does not cache the manufacturer string, and this will return None regardless of whether a descriptor exists.
Source

pub fn product_string(&self) -> Option<&str>

Product string, if available without device IO.

Source

pub fn serial_number(&self) -> Option<&str>

Serial number string, if available without device IO.

Source

pub fn interfaces(&self) -> impl Iterator<Item = &InterfaceInfo>

Iterator over the device’s interfaces.

This returns summary information about the interfaces in the device’s active configuration for the purposes of matching devices prior to opening them.

Additional information about interfaces can be found in the configuration descriptor after opening the device by calling Device::active_configuration.

§Platform-specific notes:
  • Windows: this is only available for composite devices bound to the usbccgp driver, and will be empty if the entire device is bound to a specific driver.
  • Windows: When interfaces are grouped by an interface association descriptor, this returns details from the interface association descriptor and does not include each of the associated interfaces.
Source

pub fn open(&self) -> impl MaybeFuture<Output = Result<Device, Error>>

Open the device

Trait Implementations§

Source§

impl Clone for DeviceInfo

Source§

fn clone(&self) -> DeviceInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeviceInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.