use std::io::Error; pub type Result = std::result::Result; #[derive(Debug, thiserror::Error)] pub enum TransError { #[error("{0}")] Invalid(#[from] ProtocolError), #[error("connection error: `{0}`")] Other(#[from] anyhow::Error), } impl From for TransError { fn from(err: Error) -> Self { Self::Other(err.into()) } } #[derive(Debug, thiserror::Error)] pub enum ProtocolError { #[error("fatal error")] Fatal, #[error("{0}")] ConException(#[from] ConException), #[error("{0}")] ChannelException(#[from] ChannelException), #[error("closing connection")] OtherCloseConnection, } #[derive(Debug, thiserror::Error)] pub enum ConException { #[error("501 Frame error")] FrameError, #[error("503 Command invalid")] CommandInvalid, #[error("503 Syntax error")] /// A method was received but there was a syntax error. The string stores where it occured. SyntaxError(Vec), #[error("504 Channel error")] ChannelError, #[error("xxx Not decided yet")] Todo, } #[derive(Debug, thiserror::Error)] pub enum ChannelException {}