use std::fmt;
use std::io;
use std::path::PathBuf;
#[derive(Debug)]
#[non_exhaustive]
pub enum EvdevError {
Enumerate(io::Error),
Open {
path: PathBuf,
source: io::Error,
},
NoDevices,
}
impl fmt::Display for EvdevError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Enumerate(_) => f.write_str("listing input devices"),
Self::Open { path, .. } => write!(f, "opening {}", path.display()),
Self::NoDevices => f.write_str("no usable pointer, touch or keyboard device found"),
}
}
}
impl std::error::Error for EvdevError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::Enumerate(source) | Self::Open { source, .. } => Some(source),
Self::NoDevices => None,
}
}
}