1use thiserror::Error;
2
3#[derive(Error, Debug)]
5pub enum ServerError {
6 #[error("could not initialize HID API: {0}")]
8 HidApi(#[from] hidapi::HidError),
9 #[error("failed to clone UdpSocket: {0}")]
11 UdpSocketCloneFailed(std::io::Error),
12 #[error("UdpSocket operation error: {0}")]
14 UdpSocketOperationError(std::io::Error),
15}
16
17#[derive(Error, Debug)]
19pub enum DeviceError {
20 #[error("Failed to open Device")]
22 NoDeviceFound,
23 #[error("IO Error: {0}")]
25 IO(#[from] std::io::Error),
26 #[error("HID Error: {0}")]
28 Hid(#[from] hidapi::HidError),
29 #[error("Short read: got {0} bytes, expected at least {1}")]
31 ShortRead(usize, usize),
32 #[error("Invalid report (first byte: 0x{0:02x})")]
34 InvalidReport(u8),
35}