1use crate::parser::Invalid;
2use crate::Type;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub enum Error {
7 UnknownSubType(Type, u8),
9
10 UnknownType(u8),
12
13 Invalid,
15}
16
17impl From<Invalid> for Error {
18 fn from(_: Invalid) -> Self {
19 Self::Invalid
20 }
21}
22
23impl core::error::Error for Error {}
24impl core::fmt::Display for Error {
25 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
26 match self {
27 Self::UnknownSubType(t, st) => write!(f, "unknown {t:?} sub-type: {st}"),
28 Self::UnknownType(t) => write!(f, "unknown device path type: {t}"),
29 Self::Invalid => write!(f, "invalid data format"),
30 }
31 }
32}