aboutsummaryrefslogtreecommitdiff
path: root/src/result.rs
blob: 47302aea9c9378815d36b63346d3a4d120b7f750 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::error::Error;
use std::fmt::{Debug, Display};
use std::io;

pub type ArchiveResult<R> = Result<R, ArchiveError>;

#[derive(Debug)]
pub enum ArchiveError {
    IO(io::Error),
}

impl From<io::Error> for ArchiveError {
    fn from(value: io::Error) -> Self {
        Self::IO(value)
    }
}

impl Display for ArchiveError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::IO(err) => write!(f, "{err}"),
        }
    }
}

impl Error for ArchiveError {
    fn source(&self) -> Option<&(dyn Error + 'static)> {
        match self {
            Self::IO(source) => Some(source),
        }
    }
}