rusty-keys/src/error.rs

42 lines
674 B
Rust
Raw Normal View History

2016-04-24 22:32:24 -04:00
use std::ffi;
use nix;
#[cfg(feature = "udev")]
use udev;
2016-04-25 11:57:45 -04:00
/// UInput error.
2016-04-24 22:32:24 -04:00
#[derive(Debug)]
pub enum Error {
2016-04-25 11:57:45 -04:00
/// System errors.
2016-04-24 22:32:24 -04:00
Nix(nix::Error),
2016-04-25 11:57:45 -04:00
/// Errors with internal nulls in names.
2016-04-24 22:32:24 -04:00
Nul(ffi::NulError),
#[cfg(feature = "udev")]
2016-04-25 11:57:45 -04:00
/// Errors coming from udev.
2016-04-24 22:32:24 -04:00
Udev(udev::Error),
2016-04-25 11:57:45 -04:00
/// The uinput file could not be found.
2016-04-24 22:32:24 -04:00
NotFound,
}
impl From<ffi::NulError> for Error {
fn from(value: ffi::NulError) -> Self {
Error::Nul(value)
}
}
impl From<nix::Error> for Error {
fn from(value: nix::Error) -> Self {
Error::Nix(value)
}
}
#[cfg(feature = "udev")]
impl From<udev::Error> for Error {
fn from(value: udev::Error) -> Self {
Error::Udev(value)
}
}