async_ssh2/
error.rs

1use std::{convert::From, error, fmt, io};
2
3/// Representation of an error.
4#[derive(Debug)]
5pub enum Error {
6    // An error that can occur within libssh2.
7    SSH2(ssh2::Error),
8    // An io error.
9    Io(io::Error),
10}
11
12impl fmt::Display for Error {
13    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14        match self {
15            Error::Io(e) => e.fmt(f),
16            Error::SSH2(e) => e.fmt(f),
17        }
18    }
19}
20
21impl error::Error for Error {}
22
23impl From<ssh2::Error> for Error {
24    fn from(e: ssh2::Error) -> Error {
25        Error::SSH2(e)
26    }
27}
28
29impl From<io::Error> for Error {
30    fn from(e: io::Error) -> Error {
31        Error::Io(e)
32    }
33}