pub enum Field {
Variable(VariableField),
Array(ArrayField),
Constant(ConstantField),
}Expand description
A single field inside a Report.
Fields may be Variable and represent a single element of data or they may be a Array that represent multiple elements.
Fields of type Constant should be ignored by the caller.
Given a set of bytes that is a HID Report use VariableField::extract() or ArrayField::extract() to extract the value for this field, for example:
let val = field.extract(bytes).unwrap();
if val.is_signed() {
let unsigned: u32 = val.into();
} else {
let signed: i32 = val.into();
}Variants§
Variable(VariableField)
A single element of data
Array(ArrayField)
A set of multiple fields
Constant(ConstantField)
Padding
Implementations§
Source§impl Field
impl Field
Sourcepub fn id(&self) -> FieldId
pub fn id(&self) -> FieldId
Return the unique (within this report descriptor) ID for this field.
The FieldId does not exist in the actual ReportDescriptor, it is a unique ID assigned by this crate to later identify a given field for data extraction and/or further parsing.
Sourcepub fn collections(&self) -> &[Collection]
pub fn collections(&self) -> &[Collection]
Return the set of collections this Field belongs to or the empty slice.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Field
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnwindSafe for Field
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