1use thiserror::Error;
2
3#[derive(Debug, Error)]
5#[error("{type_name} requires {width} bits but only {remaining} bits remain at offset {offset}")]
6pub struct ValueTooWide {
7 pub type_name: &'static str,
8 pub offset: u8,
9 pub width: u8,
10 pub remaining: u8,
11}
12
13#[derive(Debug, Error)]
16pub enum EncodeError {
17 #[error("{0}")]
18 ValueTooWide(#[from] ValueTooWide),
19}
20
21#[derive(Debug, Error)]
23pub enum DecodeError {
24 #[error("{0}")]
25 ValueTooWide(#[from] ValueTooWide),
26 #[error("Type {typ} has no value {disc}")]
27 NotFound { typ: &'static str, disc: i64 },
28 #[error("Successfully parsed {typ} but trailing bits were not zero: {value}")]
29 TrailingBits { typ: &'static str, value: i64 },
30}