Struct nusb::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 instance_id(&self) -> &OsStr

(Windows-only) Instance ID path of this device

source

pub fn parent_instance_id(&self) -> &OsStr

(Windows-only) Instance ID path of the parent hub

source

pub fn port_number(&self) -> u32

(Windows-only) Port number

source

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

(Windows-only) Driver associated with the device as a whole

source

pub fn bus_number(&self) -> u8

Number identifying 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 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 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.

§Platform-specific notes
  • On Windows, this comes from a case-insensitive instance ID and may have been converted to upper case from the descriptor string. It is recommended to use a case-insensitive comparison when matching a device.
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) -> Result<Device, Error>

Open the device

Trait Implementations§

source§

impl Clone for DeviceInfo

source§

fn clone(&self) -> DeviceInfo

Returns a copy 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> 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,

§

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>,

§

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>,

§

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.