#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ErrorKind {
Timeout,
NotConnected,
InvalidData,
InvalidVersion,
AuthFailed,
Unsupported,
StreamError,
UnknownError,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProxyError {
kind: ErrorKind,
text: String,
}
impl ProxyError {
pub fn new(kind: ErrorKind, text: impl Into<String>) -> Self {
Self {
kind: kind,
text: text.into(),
}
}
pub fn kind(&self) -> &ErrorKind {
&self.kind
}
pub fn text(&self) -> &str {
&self.text
}
}
impl From<std::io::Error> for ProxyError {
fn from(error: std::io::Error) -> Self {
Self {
kind: ErrorKind::UnknownError,
text: error.to_string(),
}
}
}