use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DecodeError {
pub message: String,
pub offset: usize,
}
impl DecodeError {
pub(super) fn duplicate_key(key: &str, offset: usize) -> Self {
DecodeError {
message: format!("`{key}` is already set in this map"),
offset,
}
}
}
impl fmt::Display for DecodeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "byte {}: {}", self.offset, self.message)
}
}
impl std::error::Error for DecodeError {}