pub struct Device { /* private fields */ }
Expand description
Represents a single device in the USB database.
Every device has a corresponding vendor, a device ID, a pretty name,
and a list of associated Interface
s.
Implementations§
source§impl Device
impl Device
sourcepub fn from_vid_pid(vid: u16, pid: u16) -> Option<&'static Device>
pub fn from_vid_pid(vid: u16, pid: u16) -> Option<&'static Device>
Returns the Device
corresponding to the given vendor and product IDs,
or None
if no such device exists in the DB.
use usb_ids::Device;
let device = Device::from_vid_pid(0x1d6b, 0x0003).unwrap();
assert_eq!(device.name(), "3.0 root hub");
sourcepub fn vendor(&self) -> &'static Vendor
pub fn vendor(&self) -> &'static Vendor
Returns the Vendor
that this device belongs to.
Looking up a vendor by device is cheap (O(1)
).
sourcepub fn as_vid_pid(&self) -> (u16, u16)
pub fn as_vid_pid(&self) -> (u16, u16)
Returns a tuple of (vendor id, device/“product” id) for this device.
This is convenient for interactions with other USB libraries.
sourcepub fn interfaces(&self) -> impl Iterator<Item = &'static Interface>
pub fn interfaces(&self) -> impl Iterator<Item = &'static Interface>
Returns an iterator over the device’s Interface
s.
NOTE: The USB database does not include interface information for most devices. This list is not authoritative.
Trait Implementations§
source§impl PartialEq for Device
impl PartialEq for Device
impl Copy for Device
impl Eq for Device
impl StructuralPartialEq for Device
Auto Trait Implementations§
impl Freeze for Device
impl RefUnwindSafe for Device
impl Send for Device
impl Sync for Device
impl Unpin for Device
impl UnwindSafe for Device
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)