1use core::fmt;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum SerError {
11 BufferTooSmall,
13 StringTooLong,
15 SequenceTooLong,
17}
18
19impl fmt::Display for SerError {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 SerError::BufferTooSmall => write!(f, "buffer too small"),
23 SerError::StringTooLong => write!(f, "string too long"),
24 SerError::SequenceTooLong => write!(f, "sequence too long"),
25 }
26 }
27}
28
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
31pub enum DeserError {
32 UnexpectedEof,
34 InvalidData,
36 InvalidUtf8,
38 CapacityExceeded,
40 InvalidHeader,
42}
43
44impl fmt::Display for DeserError {
45 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
46 match self {
47 DeserError::UnexpectedEof => write!(f, "unexpected end of buffer"),
48 DeserError::InvalidData => write!(f, "invalid data"),
49 DeserError::InvalidUtf8 => write!(f, "invalid UTF-8"),
50 DeserError::CapacityExceeded => write!(f, "capacity exceeded"),
51 DeserError::InvalidHeader => write!(f, "invalid encapsulation header"),
52 }
53 }
54}