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 #[error("recursive type nesting exceeded 64 levels")]
16 RecursionLimitExceeded,
17 #[error("field `{field}`: constraint violation: {message}")]
19 ConstraintViolation {
20 field: &'static str,
21 message: String,
22 },
23}
24
25#[derive(Debug, Clone, PartialEq, thiserror::Error)]
27pub enum DecodeError {
28 #[error("unexpected end of input")]
30 UnexpectedEof,
31 #[error("invalid UTF-8 in string field")]
33 InvalidUtf8,
34 #[error("invalid or overlong varint encoding")]
36 InvalidVarint,
37 #[error("field `{field}`: length {actual} exceeds limit {limit}")]
39 LimitExceeded {
40 field: &'static str,
41 limit: u64,
42 actual: u64,
43 },
44 #[error("unknown enum variant {value} for type `{type_name}`")]
46 UnknownEnumVariant { type_name: &'static str, value: u64 },
47 #[error("unknown union variant {discriminant} for type `{type_name}`")]
49 UnknownUnionVariant {
50 type_name: &'static str,
51 discriminant: u64,
52 },
53 #[error("decoded removed field ordinal {ordinal} (removed in {removed_in}): {reason}")]
55 RemovedField {
56 ordinal: u16,
57 removed_in: &'static str,
58 reason: &'static str,
59 },
60 #[error("field `{field}`: {message}")]
62 InvalidValue {
63 field: &'static str,
64 message: String,
65 },
66 #[error("recursive type nesting exceeded 64 levels")]
68 RecursionLimitExceeded,
69 #[error("schema hash mismatch")]
71 SchemaMismatch { local: [u8; 32], remote: [u8; 32] },
72}