use std::io;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("connection failed: {0}")]
Connection(String),
#[error("authentication failed: {0}")]
Auth(String),
#[error("path not found: {0}")]
NotFound(String),
#[error("permission denied: {0}")]
PermissionDenied(String),
#[error("protocol error: {0}")]
Protocol(String),
#[error("unsupported operation: {0}")]
Unsupported(String),
#[error("feature not enabled: {0}")]
FeatureDisabled(&'static str),
#[error("not connected")]
NotConnected,
#[error("io error: {0}")]
Io(#[from] io::Error),
#[error("{0}")]
Other(String),
}
pub type Result<T> = std::result::Result<T, Error>;
#[cfg(feature = "smb")]
impl From<smb2::Error> for Error {
fn from(err: smb2::Error) -> Self {
Error::Protocol(err.to_string())
}
}
#[cfg(feature = "ftp")]
impl From<async_ftp::FtpError> for Error {
fn from(err: async_ftp::FtpError) -> Self {
Error::Protocol(err.to_string())
}
}
#[cfg(feature = "sftp")]
impl From<async_ssh2_tokio::Error> for Error {
fn from(err: async_ssh2_tokio::Error) -> Self {
Error::Protocol(err.to_string())
}
}
#[cfg(feature = "sftp")]
impl From<russh_sftp::client::error::Error> for Error {
fn from(err: russh_sftp::client::error::Error) -> Self {
Error::Protocol(err.to_string())
}
}