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
use async_std;
use thiserror;

use evdev;
use evdev_rs;

use crate::events;
use crate::recorder;

pub type Result<T> = std::result::Result<T, Error>;

#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[error("io error")]
    IO(#[from] std::io::Error),

    #[error("io error")]
    NoSupportedKeys,

    #[error("io error")]
    NoEvents,

    #[error("async error")]
    AsyncSendInputEvent(#[from] async_std::channel::SendError<events::InputEvent>),

    #[error("async error")]
    AsyncSendLog(#[from] async_std::channel::SendError<recorder::Log>),

    #[error("unrecognized InputEvent\n time: {:?}, code: {:?}, value: {:?}", .e.time, .e.code, .e.state)]
    UnrecognizedInputEvent { e: events::InputEvent },

    #[error("unrecognized evdev::InputEvent:\n time: {:?}, code: {:?}, value: {:?}", .e.timestamp(), .e.code(), .e.value())]
    UnrecognizedEvdevInputEvent { e: evdev::InputEvent },

    #[error("unrecognized evdev_rs::InputEvent:\n time: {:?}, type: {:?}, code: {:?}, value: {:?}", .e.time, .e.event_type(), .e.event_code, .e.value)]
    UnrecognizedEvdevRSInputEvent { e: evdev_rs::InputEvent },

    #[error("time error")]
    SystemTimeError(#[from] std::time::SystemTimeError),
}