1use std::fmt::{self, Display};
2
3use crate::{DecodeError, EncodeError};
4
5#[derive(Debug)]
7pub enum Error {
8 DecodeError(DecodeError),
10 EncodeError(EncodeError),
12}
13
14impl From<DecodeError> for Error {
15 fn from(error: DecodeError) -> Self {
16 Self::DecodeError(error)
17 }
18}
19
20impl From<EncodeError> for Error {
21 fn from(error: EncodeError) -> Self {
22 Self::EncodeError(error)
23 }
24}
25
26impl Display for Error {
27 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
28 match self {
29 Self::DecodeError(e) => write!(f, "{}", e),
30 Self::EncodeError(e) => write!(f, "{}", e),
31 }
32 }
33}
34
35impl std::error::Error for Error {}