hidpp/channel/error.rs
1//! The errors a HID or HID++ channel operation can fail with.
2
3use std::error::Error;
4
5use thiserror::Error;
6
7/// Represents an error that occurred when creating or interacting with a HID or
8/// HID++ communication channel.
9#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum ChannelError {
12 /// Indicates that the concrete implementation of
13 /// [`RawHidChannel`](super::RawHidChannel) returned an error.
14 #[error("the HID channel implementation returned an error")]
15 Implementation(#[from] Box<dyn Error + Sync + Send>),
16
17 /// Indicates that the HID report descriptor could not be parsed.
18 #[error("the report descriptor could not be parsed")]
19 ReportDescriptor(hidreport::ParserError),
20
21 /// Indicates that the channel in question does not support HID++.
22 #[error("the HID channel does not support HID++")]
23 HidppNotSupported,
24
25 /// Indicates that the HID++ channel does not support messages of the given
26 /// type (short/long).
27 #[error("the channel does not support the given HID++ message type")]
28 MessageTypeNotSupported,
29
30 /// Indicates that a raw output report was empty or exceeded 64 bytes.
31 #[error("raw HID reports must contain 1..=64 bytes, got {0}")]
32 InvalidRawReportLength(usize),
33
34 /// Indicates that no response was received following a request.
35 #[error("the device did not respond to the request")]
36 NoResponse,
37
38 /// Indicates that a bounded channel operation did not complete — typically
39 /// because the device is asleep, out of range, connected to another host,
40 /// or its transport write is wedged. See
41 /// [`HidppChannel::send_with_timeout`](super::HidppChannel::send_with_timeout)
42 /// and
43 /// [`HidppChannel::write_raw_report`](super::HidppChannel::write_raw_report).
44 #[error("the HID channel operation timed out")]
45 Timeout,
46}