use std::string::FromUtf8Error;
use thiserror::Error;
pub type CodecResult<T> = Result<T, CodecError>;
#[derive(Debug, Error)]
pub enum CodecError {
#[error("missing required prefix '{prefix}'")]
MissingPrefix {
prefix: String,
},
#[error("hex input contains an odd number of digits: {digits}")]
OddHexLength {
digits: usize,
},
#[error("invalid hex digit '{character}' at index {index}")]
InvalidHexDigit {
index: usize,
character: char,
},
#[error("invalid base64 input: {source}")]
InvalidBase64 {
#[from]
source: base64::DecodeError,
},
#[error("invalid percent escape at index {index}")]
InvalidPercentEscape {
index: usize,
},
#[error("decoded bytes are not valid UTF-8: {source}")]
InvalidUtf8 {
#[from]
source: FromUtf8Error,
},
}