async_hid/
traits.rs

1use std::future::Future;
2
3use crate::HidResult;
4
5/// Provides functionality for reading from HID devices
6pub trait AsyncHidRead {
7    /// Read an input report from a HID device.
8    ///
9    /// The submitted buffer must be big enough to contain the entire report or the report will be truncated
10    /// If the device uses numbered report the first byte will contain the report id
11    fn read_input_report<'a>(&'a mut self, buf: &'a mut [u8]) -> impl Future<Output = HidResult<usize>> + Send + 'a;
12}
13
14/// Provides functionality for writing to HID devices
15pub trait AsyncHidWrite {
16    /// Write an output report to a HID device
17    ///
18    /// If the submitted report is larger that what the device expects it might be truncated depending on the backend
19    /// The first byte must be the report id. If the device does not use numbered report the first by must be set to 0x0
20    fn write_output_report<'a>(&'a mut self, buf: &'a [u8]) -> impl Future<Output = HidResult<()>> + Send + 'a;
21}