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("feature not enabled: {0}")]
25 FeatureDisabled(&'static str),
26
27 #[error("not connected")]
28 NotConnected,
29
30 #[error("io error: {0}")]
31 Io(#[from] io::Error),
32
33 #[error("{0}")]
34 Other(String),
35}
36
37pub type Result<T> = std::result::Result<T, Error>;
38
39#[cfg(feature = "smb")]
40impl From<smb2::Error> for Error {
41 fn from(err: smb2::Error) -> Self {
42 Error::Protocol(err.to_string())
43 }
44}
45
46#[cfg(feature = "ftp")]
47impl From<async_ftp::FtpError> for Error {
48 fn from(err: async_ftp::FtpError) -> Self {
49 Error::Protocol(err.to_string())
50 }
51}
52
53#[cfg(feature = "sftp")]
54impl From<async_ssh2_tokio::Error> for Error {
55 fn from(err: async_ssh2_tokio::Error) -> Self {
56 Error::Protocol(err.to_string())
57 }
58}
59
60#[cfg(feature = "sftp")]
61impl From<russh_sftp::client::error::Error> for Error {
62 fn from(err: russh_sftp::client::error::Error) -> Self {
63 Error::Protocol(err.to_string())
64 }
65}