1#[derive(Debug, Clone, PartialEq, thiserror::Error)]
2pub enum EncodeError {
3 #[error("field `{field}`: value does not fit in {bits} bits")]
4 ValueOutOfRange { field: &'static str, bits: u8 },
5 #[error("field `{field}`: length {actual} exceeds limit {limit}")]
6 LimitExceeded {
7 field: &'static str,
8 limit: u64,
9 actual: u64,
10 },
11}
12
13#[derive(Debug, Clone, PartialEq, thiserror::Error)]
14pub enum DecodeError {
15 #[error("unexpected end of input")]
16 UnexpectedEof,
17 #[error("invalid UTF-8 in string field")]
18 InvalidUtf8,
19 #[error("invalid or overlong varint encoding")]
20 InvalidVarint,
21 #[error("field `{field}`: length {actual} exceeds limit {limit}")]
22 LimitExceeded {
23 field: &'static str,
24 limit: u64,
25 actual: u64,
26 },
27 #[error("unknown enum variant {value} for type `{type_name}`")]
28 UnknownEnumVariant { type_name: &'static str, value: u64 },
29 #[error("unknown union variant {discriminant} for type `{type_name}`")]
30 UnknownUnionVariant {
31 type_name: &'static str,
32 discriminant: u64,
33 },
34 #[error("decoded removed field ordinal {ordinal} (removed in {removed_in}): {reason}")]
35 RemovedField {
36 ordinal: u16,
37 removed_in: &'static str,
38 reason: &'static str,
39 },
40 #[error("field `{field}`: {message}")]
41 InvalidValue {
42 field: &'static str,
43 message: String,
44 },
45 #[error("recursive type nesting exceeded 64 levels")]
46 RecursionLimitExceeded,
47 #[error("schema hash mismatch")]
48 SchemaMismatch { local: [u8; 32], remote: [u8; 32] },
49}