ripple_address_codec/
error.rs

1use std::{error, fmt};
2
3use Error::DecodeError;
4
5/// Error type with a single DecodeError variant
6#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
7pub enum Error {
8    /// Decoding error
9    ///
10    /// This error appears in various cases: bad alphabet,
11    /// prefix, payload length or bad checksum.
12    DecodeError,
13}
14
15impl error::Error for Error {}
16
17impl fmt::Display for Error {
18    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19        match self {
20            DecodeError => f.write_str("decode error"),
21        }
22    }
23}
24
25macro_rules! impl_from_error {
26    ($t:ty => $m:ident) => {
27        #[doc(hidden)]
28        impl From<$t> for Error {
29            fn from(_: $t) -> Self {
30                $m
31            }
32        }
33    };
34}
35
36impl_from_error!(base_x::DecodeError => DecodeError);