use std::fmt;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("{0}")]
Custom(String),
#[error("sequence has too many items, limit is 2^32")]
TooManyItems,
#[error(transparent)]
Binary(#[from] binary_stream::BinaryError),
#[error(transparent)]
TryFromSlice(#[from] std::array::TryFromSliceError),
#[error(transparent)]
Boxed(#[from] Box<dyn std::error::Error + Send + Sync>),
}
impl serde::ser::Error for Error {
#[cold]
fn custom<T: fmt::Display>(msg: T) -> Self {
Self::Custom(msg.to_string())
}
}
impl serde::de::Error for Error {
#[cold]
fn custom<T: fmt::Display>(msg: T) -> Self {
Self::Custom(msg.to_string())
}
}