#![allow(missing_docs)]
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
#[error("{kind}")]
pub struct Error {
#[source]
pub kind: Kind,
}
#[derive(Debug, thiserror::Error)]
pub enum Kind {
#[error("Overshot the provided len {0} > {1}")]
OvershotProvidedLen(usize, usize),
#[error("Undershot the provided len {0} < {1}")]
UndershotProvidedLen(usize, usize),
#[error("Object of length {0} is too large to be serialized (maximum allowed is 2^30 - 1)")]
LenOverflow(usize),
#[error("Custom error: {0}")]
Message(String),
#[error("Tried to serialize a key without a value")]
KeyAfterKey,
#[error("Tried to serialize a value before its key")]
ValueAfterValue,
}
impl Error {
pub fn custom(message: impl std::fmt::Display) -> Self {
Self {
kind: Kind::Message(message.to_string()),
}
}
}