pub struct FieldValue { /* private fields */ }Expand description
A wrapper around the value of a Field inside a HID Report’s byte array. This value may be signed, depending on the Field.
let bytes: Vec<u8> = read_from_device();
let val = field.extract(bytes.as_slice()).unwrap();
if val.is_signed() {
let unsigned: u32 = val.into();
} else {
let signed: i32 = val.into();
}The value is always of size u32 or i32, regardless of the number of bits in the HID Report. Cast to u16, u8, etc. as needed.
Implementations§
Trait Implementations§
Source§impl Clone for FieldValue
impl Clone for FieldValue
Source§fn clone(&self) -> FieldValue
fn clone(&self) -> FieldValue
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 FieldValue
impl Debug for FieldValue
Source§impl From<&FieldValue> for i16
impl From<&FieldValue> for i16
Source§fn from(v: &FieldValue) -> i16
fn from(v: &FieldValue) -> i16
Converts to this type from the input type.
Source§impl From<&FieldValue> for i32
impl From<&FieldValue> for i32
Source§fn from(v: &FieldValue) -> i32
fn from(v: &FieldValue) -> i32
Converts to this type from the input type.
Source§impl From<&FieldValue> for i8
impl From<&FieldValue> for i8
Source§fn from(v: &FieldValue) -> i8
fn from(v: &FieldValue) -> i8
Converts to this type from the input type.
Source§impl From<&FieldValue> for u16
impl From<&FieldValue> for u16
Source§fn from(v: &FieldValue) -> u16
fn from(v: &FieldValue) -> u16
Converts to this type from the input type.
Source§impl From<&FieldValue> for u32
impl From<&FieldValue> for u32
Source§fn from(v: &FieldValue) -> u32
fn from(v: &FieldValue) -> u32
Converts to this type from the input type.
Source§impl From<&FieldValue> for u8
impl From<&FieldValue> for u8
Source§fn from(v: &FieldValue) -> u8
fn from(v: &FieldValue) -> u8
Converts to this type from the input type.
Source§impl From<FieldValue> for i16
impl From<FieldValue> for i16
Source§fn from(f: FieldValue) -> i16
fn from(f: FieldValue) -> i16
Converts to this type from the input type.
Source§impl From<FieldValue> for i32
impl From<FieldValue> for i32
Source§fn from(f: FieldValue) -> i32
fn from(f: FieldValue) -> i32
Converts to this type from the input type.
Source§impl From<FieldValue> for i8
impl From<FieldValue> for i8
Source§fn from(f: FieldValue) -> i8
fn from(f: FieldValue) -> i8
Converts to this type from the input type.
Source§impl From<FieldValue> for u16
impl From<FieldValue> for u16
Source§fn from(f: FieldValue) -> u16
fn from(f: FieldValue) -> u16
Converts to this type from the input type.
Source§impl From<FieldValue> for u32
impl From<FieldValue> for u32
Source§fn from(f: FieldValue) -> u32
fn from(f: FieldValue) -> u32
Converts to this type from the input type.
Source§impl From<FieldValue> for u8
impl From<FieldValue> for u8
Source§fn from(f: FieldValue) -> u8
fn from(f: FieldValue) -> u8
Converts to this type from the input type.
impl Copy for FieldValue
Auto Trait Implementations§
impl Freeze for FieldValue
impl RefUnwindSafe for FieldValue
impl Send for FieldValue
impl Sync for FieldValue
impl Unpin for FieldValue
impl UnwindSafe for FieldValue
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