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