1use core::fmt;
2
3use embedded_io::ErrorKind;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum Error {
12 Io(ErrorKind),
14 Other,
16}
17
18impl core::error::Error for Error {}
19
20impl embedded_io::Error for Error {
21 fn kind(&self) -> ErrorKind {
22 match self {
23 Error::Io(kind) => *kind,
24 Error::Other => ErrorKind::Other,
25 }
26 }
27}
28
29impl From<ErrorKind> for Error {
30 fn from(kind: ErrorKind) -> Self {
31 Error::Io(kind)
32 }
33}
34
35impl fmt::Display for Error {
36 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37 match self {
38 Error::Io(kind) => write!(f, "io error: {kind:?}"),
39 Error::Other => write!(f, "shell error"),
40 }
41 }
42}
43
44pub type Result<T> = core::result::Result<T, Error>;