openssl_rehash/
error.rs

1/// A [`Result`] alias where the [`Err`] case is [`openssl_rehash::Error`](crate::Error)
2pub type Result<T> = std::result::Result<T, Error>;
3
4/// The Errors that may occur when rehashing a directory
5#[derive(Debug)]
6pub enum Error {
7    Io(std::io::Error),
8    OpenSsl(openssl::error::ErrorStack),
9}
10
11impl std::error::Error for Error {
12    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
13        match *self {
14            Error::Io(_) => None,
15            Error::OpenSsl(_) => None,
16        }
17    }
18}
19
20impl std::fmt::Display for Error {
21    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
22        match *self {
23            Error::Io(ref err) => err.fmt(f),
24            Error::OpenSsl(ref err) => err.fmt(f),
25        }
26    }
27}
28
29impl From<std::io::Error> for Error {
30    fn from(err: std::io::Error) -> Error {
31        Error::Io(err)
32    }
33}
34
35impl From<openssl::error::ErrorStack> for Error {
36    fn from(err: openssl::error::ErrorStack) -> Error {
37        Error::OpenSsl(err)
38    }
39}