1use async_std;
2use thiserror;
3
4use evdev;
5use evdev_rs;
6
7use crate::events;
8use crate::recorder;
9
10pub type Result<T> = std::result::Result<T, Error>;
11
12#[derive(thiserror::Error, Debug)]
13pub enum Error {
14 #[error("io error")]
15 IO(#[from] std::io::Error),
16
17 #[error("io error")]
18 NoSupportedKeys,
19
20 #[error("io error")]
21 NoEvents,
22
23 #[error("async error")]
24 AsyncSendInputEvent(#[from] async_std::channel::SendError<events::InputEvent>),
25
26 #[error("async error")]
27 AsyncSendLog(#[from] async_std::channel::SendError<recorder::Log>),
28
29 #[error("unrecognized InputEvent\n time: {:?}, code: {:?}, value: {:?}", .e.time, .e.code, .e.state)]
30 UnrecognizedInputEvent { e: events::InputEvent },
31
32 #[error("unrecognized evdev::InputEvent:\n time: {:?}, code: {:?}, value: {:?}", .e.timestamp(), .e.code(), .e.value())]
33 UnrecognizedEvdevInputEvent { e: evdev::InputEvent },
34
35 #[error("unrecognized evdev_rs::InputEvent:\n time: {:?}, type: {:?}, code: {:?}, value: {:?}", .e.time, .e.event_type(), .e.event_code, .e.value)]
36 UnrecognizedEvdevRSInputEvent { e: evdev_rs::InputEvent },
37
38 #[error("time error")]
39 SystemTimeError(#[from] std::time::SystemTimeError),
40}