use alloc::string::String;
use core::fmt;
#[derive(Debug)]
#[non_exhaustive]
pub enum Error {
Transport(String),
Io(String),
Codec(String),
Closed,
Auth(String),
Unsupported(&'static str),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Transport(message) => write!(f, "transport error: {message}"),
Self::Io(message) => write!(f, "io error: {message}"),
Self::Codec(message) => write!(f, "codec error: {message}"),
Self::Closed => f.write_str("resource is closed"),
Self::Auth(message) => write!(f, "authentication error: {message}"),
Self::Unsupported(capability) => {
write!(f, "unsupported capability: {capability}")
}
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for Error {}
pub type Result<T> = core::result::Result<T, Error>;