use displaydoc::Display;
use thiserror::Error;
#[derive(Debug, Error, Display)]
pub enum AnotifyError {
Init(InitError),
}
#[derive(Debug, Error, Display)]
pub enum InitError {
Inotify(#[from] nix::errno::Errno),
AsyncFd(#[from] std::io::Error),
}
macro_rules! intoerror {
() => {};
($from:ty => $discriminant:ident; $($rest:tt)*) => {
impl From<$from> for AnotifyError {
fn from(_: $from) -> Self {
Self::$discriminant
}
}
intoerror!($($rest)*);
};
($from:ty => $discriminant:ident ($using:ident); $($rest:tt)*) => {
impl From<$from> for AnotifyError {
fn from($using: $from) -> Self {
Self::$discriminant($using)
}
}
intoerror!($($rest)*);
}
}
intoerror! {
InitError => Init(it);
}