use core::fmt;
use embedded_io::ErrorKind;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Error {
Io(ErrorKind),
Other,
}
impl core::error::Error for Error {}
impl embedded_io::Error for Error {
fn kind(&self) -> ErrorKind {
match self {
Error::Io(kind) => *kind,
Error::Other => ErrorKind::Other,
}
}
}
impl From<ErrorKind> for Error {
fn from(kind: ErrorKind) -> Self {
Error::Io(kind)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Io(kind) => write!(f, "io error: {kind:?}"),
Error::Other => write!(f, "shell error"),
}
}
}
pub type Result<T> = core::result::Result<T, Error>;