1use std::fmt;
4use std::io;
5use std::path::PathBuf;
6
7#[derive(Debug)]
9#[non_exhaustive]
10pub enum EvdevError {
11 Enumerate(io::Error),
13
14 Open {
19 path: PathBuf,
21 source: io::Error,
23 },
24
25 NoDevices,
27}
28
29impl fmt::Display for EvdevError {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 match self {
32 Self::Enumerate(_) => f.write_str("listing input devices"),
33 Self::Open { path, .. } => write!(f, "opening {}", path.display()),
34 Self::NoDevices => f.write_str("no usable pointer, touch or keyboard device found"),
35 }
36 }
37}
38
39impl std::error::Error for EvdevError {
40 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
41 match self {
42 Self::Enumerate(source) | Self::Open { source, .. } => Some(source),
43 Self::NoDevices => None,
44 }
45 }
46}