1use std::fmt;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
6pub enum Error {
7 #[error("{0}")]
9 Custom(String),
10
11 #[error("sequence has too many items, limit is 2^32")]
13 TooManyItems,
14
15 #[error(transparent)]
17 Binary(#[from] binary_stream::BinaryError),
18
19 #[error(transparent)]
21 TryFromSlice(#[from] std::array::TryFromSliceError),
22
23 #[error(transparent)]
25 Boxed(#[from] Box<dyn std::error::Error + Send + Sync>),
26}
27
28impl serde::ser::Error for Error {
29 #[cold]
30 fn custom<T: fmt::Display>(msg: T) -> Self {
31 Self::Custom(msg.to_string())
32 }
33}
34
35impl serde::de::Error for Error {
36 #[cold]
37 fn custom<T: fmt::Display>(msg: T) -> Self {
38 Self::Custom(msg.to_string())
39 }
40}