pub struct Version(pub u8, pub u8, pub u8);
Expand description
The version value (for BCD and USB) is in binary coded decimal with a format of 0xJJMN where JJ is the major version number, M is the minor version number and N is the sub minor version number. e.g. USB 2.0 is reported as 0x0200, USB 1.1 as 0x0110 and USB 1.0 as 0x0100. The type is a mirror of the one from rusb in order to impl Display, From etc.
let version = cyme::usb::Version(2, 0, 1);
Represents the version 2.0.1, or in String
representation it is base16 encoded:
assert_eq!(version.to_string(), "2.01");
let version = cyme::usb::Version(155, 15, 1);
assert_eq!(version.to_string(), "9b.f1");
Tuple Fields§
§0: u8
§1: u8
§2: u8
Implementations§
source§impl Version
impl Version
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 Ord for Version
impl Ord for Version
source§impl PartialEq for Version
impl PartialEq for Version
source§impl PartialOrd for Version
impl PartialOrd for Version
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Version
impl Eq for Version
impl StructuralEq for Version
impl StructuralPartialEq for Version
Auto Trait Implementations§
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnwindSafe for Version
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