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