use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug)]
pub enum Error {
#[error("I/O 错误: {0}")]
Io(#[from] std::io::Error),
#[error("decode 错误: {0}")]
Decode(String),
#[error("connect 失败: {0}")]
Connect(String),
#[error("认证失败,status={0}")]
Auth(u8),
#[error("CONNECT_RESP 中的 AuthenticatorISMG 不匹配")]
AuthenticatorMismatch,
#[error("response 超时")]
Timeout,
#[error("connection 已关闭")]
Closed,
#[error("send channel 已关闭")]
ChannelClosed,
#[error("由 peer 终止")]
Terminated,
#[error("config 无效: {0}")]
Config(String),
}