use std::fmt;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{0}")]
Message(String),
#[error("unexpected end of input")]
Eof,
#[error("invalid boolean value: {0}")]
InvalidBool(u32),
#[error("invalid enum discriminant: {0}")]
InvalidEnumDiscriminant(i32),
#[error("invalid UTF-8 string")]
InvalidUtf8,
#[error("string length {0} exceeds maximum {1}")]
StringTooLong(usize, usize),
#[error("array length {0} exceeds maximum {1}")]
ArrayTooLong(usize, usize),
#[error("trailing data: {0} bytes remaining")]
TrailingData(usize),
}
impl serde::ser::Error for Error {
fn custom<T: fmt::Display>(msg: T) -> Self {
Error::Message(msg.to_string())
}
}
impl serde::de::Error for Error {
fn custom<T: fmt::Display>(msg: T) -> Self {
Error::Message(msg.to_string())
}
}