1use std::io;
2
3#[derive(Debug, thiserror::Error)]
5pub enum Error {
6 #[error("connection failed: {0}")]
7 Connection(String),
8
9 #[error("authentication failed: {0}")]
10 Auth(String),
11
12 #[error("path not found: {0}")]
13 NotFound(String),
14
15 #[error("permission denied: {0}")]
16 PermissionDenied(String),
17
18 #[error("protocol error: {0}")]
19 Protocol(String),
20
21 #[error("unsupported operation: {0}")]
22 Unsupported(String),
23
24 #[error("not connected")]
25 NotConnected,
26
27 #[error("io error: {0}")]
28 Io(#[from] io::Error),
29
30 #[error("{0}")]
31 Other(String),
32}
33
34pub type Result<T> = std::result::Result<T, Error>;
35
36impl From<smb2::Error> for Error {
37 fn from(err: smb2::Error) -> Self {
38 Error::Protocol(err.to_string())
39 }
40}
41
42impl From<async_ftp::FtpError> for Error {
43 fn from(err: async_ftp::FtpError) -> Self {
44 Error::Protocol(err.to_string())
45 }
46}
47
48impl From<async_ssh2_tokio::Error> for Error {
49 fn from(err: async_ssh2_tokio::Error) -> Self {
50 Error::Protocol(err.to_string())
51 }
52}
53
54impl From<russh_sftp::client::error::Error> for Error {
55 fn from(err: russh_sftp::client::error::Error) -> Self {
56 Error::Protocol(err.to_string())
57 }
58}