1use std::{error, fmt};
2
3#[derive(Debug, Copy, Clone, PartialEq, Eq)]
5pub enum EncodeError {
6 UnsupportedType,
8}
9
10impl fmt::Display for EncodeError {
11 #[inline]
12 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13 match *self {
14 EncodeError::UnsupportedType => write!(f, "This type is not supported yet"),
15 }
16 }
17}
18
19impl error::Error for EncodeError {}
20
21#[derive(Debug, Copy, Clone, PartialEq, Eq)]
23pub enum DecodeError {
24 BadInputLength,
26 UnknownCode,
28}
29
30impl fmt::Display for DecodeError {
31 #[inline]
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 match *self {
34 DecodeError::BadInputLength => write!(f, "Not matching input length"),
35 DecodeError::UnknownCode => write!(f, "Found unknown code"),
36 }
37 }
38}
39
40impl error::Error for DecodeError {}
41
42#[derive(Debug, Clone, PartialEq, Eq)]
46pub struct DecodeOwnedError {
47 pub error: DecodeError,
49 pub data: Vec<u8>,
51}
52
53impl fmt::Display for DecodeOwnedError {
54 #[inline]
55 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
56 write!(f, "{}", self.error)
57 }
58}
59
60impl error::Error for DecodeOwnedError {}