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
- Linux:
Implementations§
source§impl DeviceInfo
impl DeviceInfo
sourcepub fn sysfs_path(&self) -> &Path
pub fn sysfs_path(&self) -> &Path
(Linux-only) Sysfs path for the device.
sourcepub fn bus_number(&self) -> u8
pub fn bus_number(&self) -> u8
Number identifying the bus / host controller where the device is connected.
sourcepub fn device_address(&self) -> u8
pub fn device_address(&self) -> u8
Number identifying the device within the bus.
sourcepub fn vendor_id(&self) -> u16
pub fn vendor_id(&self) -> u16
The 16-bit number identifying the device’s vendor, from the idVendor
device descriptor field.
sourcepub fn product_id(&self) -> u16
pub fn product_id(&self) -> u16
The 16-bit number identifying the product, from the idProduct
device descriptor field.
sourcepub fn device_version(&self) -> u16
pub fn device_version(&self) -> u16
The device version, normally encoded as BCD, from the bcdDevice
device descriptor field.
sourcepub fn class(&self) -> u8
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.
sourcepub fn subclass(&self) -> u8
pub fn subclass(&self) -> u8
Standard subclass, from the bDeviceSubClass
device descriptor field.
sourcepub fn protocol(&self) -> u8
pub fn protocol(&self) -> u8
Standard protocol, from the bDeviceProtocol
device descriptor field.
sourcepub fn manufacturer_string(&self) -> Option<&str>
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.
sourcepub fn product_string(&self) -> Option<&str>
pub fn product_string(&self) -> Option<&str>
Product string, if available without device IO.
sourcepub fn serial_number(&self) -> Option<&str>
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.
sourcepub fn interfaces(&self) -> impl Iterator<Item = &InterfaceInfo>
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.
Trait Implementations§
source§impl Clone for DeviceInfo
impl Clone for DeviceInfo
source§fn clone(&self) -> DeviceInfo
fn clone(&self) -> DeviceInfo
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more