1use std::error;
2use std::fmt;
3
4pub type LocalResult<T> = Result<T, LocalError>;
5
6#[derive(Debug)]
8pub enum LocalError {
9 DecodeError(rasn::error::DecodeError),
10 EncodeError(rasn::error::EncodeError),
11 ProtocolError(String),
12}
13
14impl error::Error for LocalError {
15 fn source(&self) -> Option<&(dyn error::Error + 'static)> {
16 match *self {
17 Self::DecodeError(ref e) => Some(e),
18 Self::EncodeError(ref e) => Some(e),
19 _ => None,
20 }
21 }
22}
23
24impl fmt::Display for LocalError {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 match *self {
27 Self::DecodeError(ref e) => write!(f, "{e}"),
28 Self::EncodeError(ref e) => write!(f, "{e}"),
29 Self::ProtocolError(ref s) => write!(f, "ProtocolError: {s}"),
30 }
31 }
32}