From 9cc48f40fbb1a0149b9e3bf9d5d7a518fecc851f Mon Sep 17 00:00:00 2001 From: diogo464 Date: Sun, 17 Jul 2022 14:23:14 +0100 Subject: impl std::error::Error for HexDecodeError --- src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index ae346a1..36790b7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,17 @@ pub enum HexDecodeError { InvalidHexCharacter, } +impl std::fmt::Display for HexDecodeError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + HexDecodeError::InvalidByteCount => write!(f, "Invalid byte count"), + HexDecodeError::InvalidHexCharacter => write!(f, "Invalid hex character"), + } + } +} + +impl std::error::Error for HexDecodeError {} + struct EncodeHexIterSlice<'data_lifetime> { //bytes to encode as hex data: &'data_lifetime [u8], -- cgit