1use core::fmt;
2use std::fmt::{Display, Formatter};
3
4#[derive(Debug)]
5pub enum ScpError {
6 Io(std::io::Error),
7 Ssh(ssh2::Error),
8 Other(String),
9}
10
11impl Display for ScpError {
12 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
13 match self {
14 ScpError::Io(e) => write!(f, "IO error: {}", e),
15 ScpError::Ssh(e) => write!(f, "SSH error: {}", e),
16 ScpError::Other(e) => write!(f, "Error: {}", e),
17 }
18 }
19}
20
21impl From<std::io::Error> for ScpError {
22 fn from(e: std::io::Error) -> Self {
23 ScpError::Io(e)
24 }
25}
26
27impl From<ssh2::Error> for ScpError {
28 fn from(e: ssh2::Error) -> Self {
29 ScpError::Ssh(e)
30 }
31}
32
33pub type Result<T = ()> = anyhow::Result<T, ScpError>;