aldrin_core/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug, Copy, Clone, PartialEq, Eq)]
4pub enum SerializeError {
5    #[error("serialized value overflowed")]
6    Overflow,
7
8    #[error("more elements serialized than expected")]
9    TooManyElements,
10
11    #[error("fewer elements serialized than expected")]
12    TooFewElements,
13
14    #[error("too deeply nested")]
15    TooDeeplyNested,
16}
17
18#[derive(Error, Debug, Copy, Clone, PartialEq, Eq)]
19pub enum DeserializeError {
20    #[error("invalid serialization")]
21    InvalidSerialization,
22
23    #[error("unexpected end of input")]
24    UnexpectedEoi,
25
26    #[error("unexpected value type")]
27    UnexpectedValue,
28
29    #[error("no more elements")]
30    NoMoreElements,
31
32    #[error("more elements remain")]
33    MoreElementsRemain,
34
35    #[error("too deeply nested")]
36    TooDeeplyNested,
37
38    #[error("serialization contains trailing data")]
39    TrailingData,
40}
41
42#[derive(Error, Debug, Copy, Clone, PartialEq, Eq)]
43#[error(transparent)]
44pub struct ProtocolVersionError {
45    #[from]
46    pub(crate) kind: ProtocolVersionErrorKind,
47}
48
49#[derive(Error, Debug, Copy, Clone, PartialEq, Eq)]
50pub(crate) enum ProtocolVersionErrorKind {
51    #[error("invalid major version component")]
52    InvalidMajor,
53
54    #[error("invalid minor version component")]
55    InvalidMinor,
56
57    #[error("version failed to parse")]
58    Parse,
59}