Struct usb_ids::UsbId

source ·
pub struct UsbId<const ID: u8, T> { /* private fields */ }
Expand description

Represents a generic USB ID in the USB database.

Not designed to be used directly; use one of the type aliases instead.

Implementations§

source§

impl<const ID: u8, T: Copy> UsbId<ID, T>

source

pub fn id(&self) -> T

Returns the type’s ID.

source

pub fn name(&self) -> &'static str

Returns the type’s name.

source§

impl UsbId<PROTOCOL_TAG, u8>

source

pub fn from_cid_scid_pid( class_id: u8, subclass_id: u8, id: u8 ) -> Option<&'static Self>

Returns the Protocol corresponding to the given class, subclass, and protocol IDs, or None if no such protocol exists in the DB.

use usb_ids::Protocol;
let protocol = Protocol::from_cid_scid_pid(0x02, 0x02, 0x05).unwrap();
assert_eq!(protocol.name(), "AT-commands (3G)");
source§

impl UsbId<HID_USAGE_TAG, u16>

source

pub fn from_pageid_uid(page_id: u8, id: u16) -> Option<&'static Self>

Returns the HidUsage corresponding to the given usage page and usage ID, or None if no such usage exists in the DB.

use usb_ids::HidUsage;
let hid_usage = HidUsage::from_pageid_uid(0x01, 0x002).unwrap();
assert_eq!(hid_usage.name(), "Mouse");
source§

impl UsbId<DIALECT_TAG, u8>

source

pub fn from_lid_did(language_id: u16, id: u8) -> Option<&'static Self>

Returns the Dialect corresponding to the given language and dialect IDs, or None if no such dialect exists in the DB.

use usb_ids::Dialect;
let dialect = Dialect::from_lid_did(0x0007, 0x02).unwrap();
assert_eq!(dialect.name(), "Swiss");

Trait Implementations§

source§

impl<const ID: u8, T: Clone> Clone for UsbId<ID, T>

source§

fn clone(&self) -> UsbId<ID, T>

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<const ID: u8, T: Debug> Debug for UsbId<ID, T>

source§

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

Formats the value using the given formatter. Read more
source§

impl<const ID: u8, T: PartialEq> PartialEq for UsbId<ID, T>

source§

fn eq(&self, other: &UsbId<ID, T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const ID: u8, T: Copy> Copy for UsbId<ID, T>

source§

impl<const ID: u8, T: Eq> Eq for UsbId<ID, T>

source§

impl<const ID: u8, T> StructuralPartialEq for UsbId<ID, T>

Auto Trait Implementations§

§

impl<const ID: u8, T> Freeze for UsbId<ID, T>
where T: Freeze,

§

impl<const ID: u8, T> RefUnwindSafe for UsbId<ID, T>
where T: RefUnwindSafe,

§

impl<const ID: u8, T> Send for UsbId<ID, T>
where T: Send,

§

impl<const ID: u8, T> Sync for UsbId<ID, T>
where T: Sync,

§

impl<const ID: u8, T> Unpin for UsbId<ID, T>
where T: Unpin,

§

impl<const ID: u8, T> UnwindSafe for UsbId<ID, T>
where T: UnwindSafe,

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.