modbus_relay/errors/kinds/
frame_error.rs

1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2pub enum FrameErrorKind {
3    TooShort,
4    TooLong,
5    InvalidFormat,
6    InvalidUnitId,
7    InvalidHeader,
8    InvalidCrc,
9    UnexpectedResponse,
10}
11
12impl std::fmt::Display for FrameErrorKind {
13    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14        match self {
15            Self::TooShort => write!(f, "Frame too short"),
16            Self::TooLong => write!(f, "Frame too long"),
17            Self::InvalidFormat => write!(f, "Invalid frame format"),
18            Self::InvalidUnitId => write!(f, "Invalid unit ID"),
19            Self::InvalidHeader => write!(f, "Invalid frame header"),
20            Self::InvalidCrc => write!(f, "Invalid frame CRC"),
21            Self::UnexpectedResponse => write!(f, "Unexpected response"),
22        }
23    }
24}