pub use std::io::{Error, ErrorKind};
pub type Result<T> = std::io::Result<T>;
#[derive(Debug)]
pub enum DropRemoveError<T> {
Recoverable(T, Error),
Terminal(Error),
}
impl<T> DropRemoveError<T> {
pub fn into_error(self) -> Error {
match self {
Self::Recoverable(_, e) => e,
Self::Terminal(e) => e,
}
}
}
impl<T> From<DropRemoveError<T>> for Error {
fn from(e: DropRemoveError<T>) -> Self {
e.into_error()
}
}
impl<T> core::fmt::Display for DropRemoveError<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Recoverable(_, e) => write!(f, "recoverable: {e}"),
Self::Terminal(e) => write!(f, "terminal: {e}"),
}
}
}
impl<T: core::fmt::Debug> core::error::Error for DropRemoveError<T> {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
Self::Recoverable(_, e) | Self::Terminal(e) => Some(e),
}
}
}