1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use thiserror::Error;
#[derive(Error, Copy, Clone, PartialEq, Eq, Debug)]
pub enum ParseError {
#[error("Received data doesn't suit header size")]
InvalidPacketSize,
#[error("Invariant not met: {0}")]
InvalidInvariant(&'static str),
#[error("Received invalid data: {0}")]
InvalidData(&'static str),
#[error("Checksum mismatch: 0x{0:x} vs 0x{1:x}")]
InvalidChecksum(u16, u16),
}
#[derive(Error, Copy, Clone, PartialEq, Eq, Debug)]
pub enum SerializeError {
#[error("Serializing header with unrecognized values")]
UnrecognizedData,
#[error("Invariant not met: {0}")]
InvalidInvariant(&'static str),
#[error("Received invalid data: {0}")]
InvalidData(&'static str),
}