1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! Platform backend selection.
//!
//! Each native backend exposes two types with an identical inherent-method
//! surface (a compile-time "trait"):
//!
//! ```text
//! pub(crate) struct PlatformApi;
//! impl PlatformApi {
//! pub fn new() -> HidResult<Self>;
//! /// vendor_id/product_id of 0 act as wildcards.
//! pub fn enumerate(&self, vendor_id: u16, product_id: u16) -> HidResult<Vec<DeviceInfo>>;
//! pub fn open(&self, vendor_id: u16, product_id: u16, serial: Option<&str>)
//! -> HidResult<PlatformDevice>;
//! pub fn open_path(&self, path: &str) -> HidResult<PlatformDevice>;
//! }
//!
//! pub(crate) struct PlatformDevice;
//! impl PlatformDevice {
//! pub fn write(&self, data: &[u8]) -> HidResult<usize>;
//! pub fn read(&self, buf: &mut [u8]) -> HidResult<usize>;
//! pub fn read_timeout(&self, buf: &mut [u8], timeout_ms: i32) -> HidResult<usize>;
//! /// Returns a Send future resolving with one input report; never 0.
//! pub fn read_async<'a>(&'a self, buf: &'a mut [u8])
//! -> impl Future<Output = HidResult<usize>> + Send + 'a;
//! pub fn set_blocking_mode(&self, blocking: bool) -> HidResult<()>;
//! pub fn send_feature_report(&self, data: &[u8]) -> HidResult<()>;
//! pub fn get_feature_report(&self, buf: &mut [u8]) -> HidResult<usize>;
//! pub fn get_input_report(&self, buf: &mut [u8]) -> HidResult<usize>;
//! pub fn get_manufacturer_string(&self) -> HidResult<Option<String>>;
//! pub fn get_product_string(&self) -> HidResult<Option<String>>;
//! pub fn get_serial_number_string(&self) -> HidResult<Option<String>>;
//! pub fn get_indexed_string(&self, index: u32) -> HidResult<Option<String>>;
//! pub fn get_report_descriptor(&self, buf: &mut [u8]) -> HidResult<usize>;
//! pub fn get_device_info(&self) -> HidResult<DeviceInfo>;
//! }
//! ```
//!
//! Semantics shared by all backends (hidapi parity):
//!
//! * `write` / `send_feature_report`: `data[0]` is the report ID; use 0 when
//! the device has no numbered reports. The ID byte counts toward the
//! returned length.
//! * `read` / `read_timeout`: input reports are prefixed with their report ID
//! only when the device uses numbered reports. `timeout_ms < 0` blocks
//! forever, `0` polls.
//! * `get_feature_report` / `get_input_report`: `buf[0]` must contain the
//! report ID on entry; on return the buffer starts with that ID.
//! * In non-blocking mode, `read` returns `Ok(0)` when no report is queued.
//! * `read_async` ignores the blocking mode, never resolves with `Ok(0)`,
//! fails with `HidError::Disconnected` on removal, and must be
//! cancel-safe: dropping the future may not lose an already-delivered
//! report (it stays queued for the next read). Wake-ups are
//! runtime-agnostic (raw `Waker`s, no executor assumed).
// The WebHID backend on wasm. Unlike the native backends below it does not
// implement the PlatformApi/PlatformDevice contract documented above (the
// `web` module in lib.rs drives it directly), but it belongs here as a backend.
pub
// With the `nusb` feature the USB-transport backend replaces the per-OS native
// backends on every platform; otherwise the native backend for the target OS
// is selected.
pub
pub use ;
pub
pub
pub use ;
pub
pub use ;
pub
pub use ;