modbus_rtu/common/
packet_error.rs

1use super::exception::Exception;
2
3
4/// Error types for received packet while analyzing it.
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub enum PacketError {
7    /// Packet is too short to analyze
8    TooShort(usize),
9
10    /// Given CRC bytes are mismatched with the expected one
11    CrcMismatch { expected: [u8; 2], found: [u8; 2] },
12
13    /// Packet is from unexpected ID
14    NotMyId(u8),
15
16    /// Device reported exception code
17    Exeption(u8, Exception),
18
19    /// Unexpected packet format
20    Invalid(&'static str),
21}