use std::io;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
FileError(io::Error),
EncodingError(rustolio_utils::Error),
StoreClosed,
NotAllowed,
}
impl From<Error> for String {
fn from(val: Error) -> Self {
val.to_string()
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{self:?}")
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::FileError(e) => Some(e),
Self::EncodingError(e) => Some(e),
Self::StoreClosed | Self::NotAllowed => None,
}
}
}