1use std::io;
12
13pub type Result<T> = std::result::Result<T, Error>;
14
15#[derive(Debug)]
16pub enum Error {
17 FileError(io::Error),
18 EncodingError(rustolio_utils::Error),
19 StoreClosed,
20 NotAllowed,
21}
22
23impl From<Error> for String {
24 fn from(val: Error) -> Self {
25 val.to_string()
26 }
27}
28
29impl std::fmt::Display for Error {
30 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31 write!(f, "{self:?}")
32 }
33}
34
35impl std::error::Error for Error {
36 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
37 match self {
38 Self::FileError(e) => Some(e),
39 Self::EncodingError(e) => Some(e),
40 Self::StoreClosed | Self::NotAllowed => None,
41 }
42 }
43}