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
use core::fmt;
use std::fmt::{Display, Formatter};

#[derive(Debug)]
pub enum ScpError {
    Io(std::io::Error),
    Ssh(ssh2::Error),
    Other(String),
}

impl Display for ScpError {
    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
        match self {
            ScpError::Io(e) => write!(f, "IO error: {}", e),
            ScpError::Ssh(e) => write!(f, "SSH error: {}", e),
            ScpError::Other(e) => write!(f, "Error: {}", e),
        }
    }
}

impl From<std::io::Error> for ScpError {
    fn from(e: std::io::Error) -> Self {
        ScpError::Io(e)
    }
}

impl From<ssh2::Error> for ScpError {
    fn from(e: ssh2::Error) -> Self {
        ScpError::Ssh(e)
    }
}