pub enum ReportItem {
Show 28 variants
Input(Input),
Output(Output),
Feature(Feature),
Collection(Collection),
EndCollection(EndCollection),
UsagePage(UsagePage),
LogicalMinimum(LogicalMinimum),
LogicalMaximum(LogicalMaximum),
PhysicalMinimum(PhysicalMinimum),
PhysicalMaximum(PhysicalMaximum),
UnitExponent(UnitExponent),
Unit(Unit),
ReportSize(ReportSize),
ReportId(ReportId),
ReportCount(ReportCount),
Push(Push),
Pop(Pop),
Usage(Usage),
UsageMinimum(UsageMinimum),
UsageMaximum(UsageMaximum),
DesignatorIndex(DesignatorIndex),
DesignatorMinimum(DesignatorMinimum),
DesignatorMaximum(DesignatorMaximum),
StringIndex(StringIndex),
StringMinimum(StringMinimum),
StringMaximum(StringMaximum),
Delimiter(Delimiter),
Reserved(Reserved),
}Expand description
Report items enumeration.
The HID Report descriptor is made up of items that provide information about the device.
All items contain a 1-byte prefix which denotes the basic type of the item. The HID class defines two basic formats for items:
- Short items: 1–5 bytes total length; used for the most commonly occurring items. A short item typically contains 1 or 0 bytes of optional data.
- Long items: 3–258 bytes in length; used for items that require larger data structures for parts.
NOTE: No long item tags are defined, these tags are reserved for future use.
The short item format packs the item size, type, and tag into the first byte. The first byte may be followed by 0, 1, 2, or 4 optional data bytes depending on the size of the data.
| Bit -8 | Bit 7-4 | Bit 3-2 | Bit 1-0 |
|---|---|---|---|
| [data] | bTag | bType | bSize |
bSize: Numeric expression specifying size of data:
| bSize | size of data |
|---|---|
| 0 | 0 bytes |
| 1 | 1 byte |
| 2 | 2 bytes |
| 3 | 4 bytes |
bType: Numeric expression identifying type of item where:
| bType | type of item |
|---|---|
| 0 | Main |
| 1 | Global |
| 2 | Local |
| 3 | Reserved |
bTag: Numeric expression specifying the function of the item.
Variants§
Input(Input)
An Input item.
Output(Output)
An Output item.
Feature(Feature)
A Feature item.
Collection(Collection)
A Collection item.
EndCollection(EndCollection)
An EndCollection item.
UsagePage(UsagePage)
A UsagePage item.
LogicalMinimum(LogicalMinimum)
A LogicalMinimum item.
LogicalMaximum(LogicalMaximum)
A LogicalMaximum item.
PhysicalMinimum(PhysicalMinimum)
A PhysicalMinimum item.
PhysicalMaximum(PhysicalMaximum)
A PhysicalMaximum item.
UnitExponent(UnitExponent)
A UnitExponent item.
Unit(Unit)
A Unit item.
ReportSize(ReportSize)
A ReportSize item.
ReportId(ReportId)
A ReportId item.
ReportCount(ReportCount)
A ReportCount item.
Push(Push)
A Push item.
Pop(Pop)
A Pop item.
Usage(Usage)
A Usage item.
UsageMinimum(UsageMinimum)
A UsageMinimum item.
UsageMaximum(UsageMaximum)
A UsageMaximum item.
DesignatorIndex(DesignatorIndex)
A DesignatorIndex item.
DesignatorMinimum(DesignatorMinimum)
A DesignatorMinimum item.
DesignatorMaximum(DesignatorMaximum)
A DesignatorMaximum item.
StringIndex(StringIndex)
A StringIndex item.
StringMinimum(StringMinimum)
A StringMinimum item.
StringMaximum(StringMaximum)
A StringMaximum item.
Delimiter(Delimiter)
A Delimiter item.
Reserved(Reserved)
A Reserved item.
Implementations§
Source§impl ReportItem
impl ReportItem
Sourcepub fn new(raw: &[u8]) -> Result<Self, HidError>
pub fn new(raw: &[u8]) -> Result<Self, HidError>
Create a new item from raw byte stream.
Items that cannot be recognized will be treated as Reserved.
If you want to fail on unknown items, use new_strict() instead.
§Example
use hid_report::ReportItem;
let raw = [0x26, 0x3c, 0x02];
let item = ReportItem::new(&raw).unwrap();
assert!(matches!(item, ReportItem::LogicalMaximum(_)));
assert_eq!(item.to_string(), "Logical Maximum (572)");Sourcepub fn new_strict(raw: &[u8]) -> Result<Self, HidError>
pub fn new_strict(raw: &[u8]) -> Result<Self, HidError>
Create a new item from raw byte stream in strict mode.
Items that cannot be recognized will be treated as HidError::ReservedItem.
Sourcepub unsafe fn new_unchecked(raw: &[u8]) -> Self
pub unsafe fn new_unchecked(raw: &[u8]) -> Self
Create a new item from raw byte stream, without checking data length.
Items that cannot be recognized will be treated as Reserved.
If you want to fail on unknown items, use
new_strict_unchecked() instead.
§Safety
You should ensure that the raw data is a valid HID report item.
Sourcepub unsafe fn new_strict_unchecked(raw: &[u8]) -> Result<Self, HidError>
pub unsafe fn new_strict_unchecked(raw: &[u8]) -> Result<Self, HidError>
Create a new item from raw byte stream in strict mode, without checking data length.
Items that cannot be recognized will be treated as HidError::ReservedItem.
Also, this is the only error that may be reported.
§Safety
You should ensure that the raw data is a valid HID report item.
Trait Implementations§
Source§impl AsRef<[u8]> for ReportItem
impl AsRef<[u8]> for ReportItem
Source§impl Clone for ReportItem
impl Clone for ReportItem
Source§fn clone(&self) -> ReportItem
fn clone(&self) -> ReportItem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more