pub struct UsbVersion(pub u8, pub u8, pub u8);
Expand description
A three-part version consisting of major, minor, and sub minor components.
The intended use case of Version
is to extract meaning from the version fields in USB
descriptors, such as bcdUSB
and bcdDevice
in device descriptors.
Tuple Fields§
§0: u8
§1: u8
§2: u8
Implementations§
Source§impl UsbVersion
impl UsbVersion
Sourcepub fn from_bcd(raw: u16) -> Self
pub fn from_bcd(raw: u16) -> Self
Extracts a version from a binary coded decimal (BCD) field. BCD fields exist in USB
descriptors as 16-bit integers encoding a version as 0xJJMN
, where JJ
is the major
version, M
is the minor version, and N
is the sub minor version. For example, 2.0 is
encoded as 0x0200
and 1.1 is encoded as 0x0110
.
Trait Implementations§
Source§impl Clone for UsbVersion
impl Clone for UsbVersion
Source§fn clone(&self) -> UsbVersion
fn clone(&self) -> UsbVersion
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for UsbVersion
impl Debug for UsbVersion
Source§impl Display for UsbVersion
impl Display for UsbVersion
Source§impl Hash for UsbVersion
impl Hash for UsbVersion
Source§impl Ord for UsbVersion
impl Ord for UsbVersion
Source§fn cmp(&self, other: &UsbVersion) -> Ordering
fn cmp(&self, other: &UsbVersion) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for UsbVersion
impl PartialEq for UsbVersion
Source§impl PartialOrd for UsbVersion
impl PartialOrd for UsbVersion
impl Copy for UsbVersion
impl Eq for UsbVersion
impl StructuralPartialEq for UsbVersion
Auto Trait Implementations§
impl Freeze for UsbVersion
impl RefUnwindSafe for UsbVersion
impl Send for UsbVersion
impl Sync for UsbVersion
impl Unpin for UsbVersion
impl UnwindSafe for UsbVersion
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