#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MeshError {
FrameTooShort,
FrameTooLong,
PayloadTooLong,
UnsupportedVersion(u8),
CrcMismatch {
expected: u16,
found: u16,
},
}
impl core::fmt::Display for MeshError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
MeshError::FrameTooShort => {
f.write_str("mesh frame is shorter than its header and checksum")
}
MeshError::FrameTooLong => {
f.write_str("mesh frame is larger than the maximum frame size")
}
MeshError::PayloadTooLong => {
f.write_str("mesh payload is larger than a single frame can carry")
}
MeshError::UnsupportedVersion(version) => {
write!(f, "unsupported mesh protocol version {version}")
}
MeshError::CrcMismatch { expected, found } => {
write!(
f,
"mesh CRC mismatch: expected {expected:#06x}, found {found:#06x}"
)
}
}
}
}
impl core::error::Error for MeshError {}