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("too deeply nested")]
33 TooDeeplyNested,
34
35 #[error("serialization contains trailing data")]
36 TrailingData,
37}
38
39#[derive(Error, Debug, Copy, Clone, PartialEq, Eq)]
40#[error(transparent)]
41pub struct ProtocolVersionError {
42 #[from]
43 pub(crate) kind: ProtocolVersionErrorKind,
44}
45
46#[derive(Error, Debug, Copy, Clone, PartialEq, Eq)]
47pub(crate) enum ProtocolVersionErrorKind {
48 #[error("invalid major version component")]
49 InvalidMajor,
50
51 #[error("invalid minor version component")]
52 InvalidMinor,
53
54 #[error("version failed to parse")]
55 Parse,
56}