| Add trait impls and slice iterators; base16ct's decoder now goes through ae9f986 nandithebull 15h ago | 1 | use core::fmt; |
| 2 | |
| 3 | /// Result type with the `base16ct` crate's [`Error`] type. |
| 4 | pub type Result<T> = core::result::Result<T, Error>; |
| 5 | |
| 6 | /// Error type |
| 7 | #[derive(Clone, Eq, PartialEq, Debug)] |
| 8 | pub enum Error { |
| 9 | /// Invalid encoding of provided Base16 string. |
| 10 | InvalidEncoding, |
| 11 | |
| 12 | /// Insufficient output buffer length. |
| 13 | InvalidLength, |
| 14 | } |
| 15 | |
| 16 | impl fmt::Display for Error { |
| 17 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 18 | match self { |
| 19 | Error::InvalidEncoding => f.write_str("invalid Base16 encoding"), |
| 20 | Error::InvalidLength => f.write_str("invalid Base16 length"), |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | impl core::error::Error for Error {} |
| 26 | |
| 27 | impl From<Error> for fmt::Error { |
| 28 | fn from(_: Error) -> fmt::Error { |
| 29 | fmt::Error |
| 30 | } |
| 31 | } |