use std::fmt;
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Error {
ToShort,
ToLong,
InvalidChar,
InvalidZero,
TimestampOutOfRange,
RandomnessOutOfRange,
}
impl std::error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let message = match *self {
Self::ToShort => "string is too short",
Self::ToLong => "string is too long",
Self::InvalidChar => "string contains an invalid character",
Self::InvalidZero => "invalid zero value",
Self::TimestampOutOfRange => "timestamp is too large",
Self::RandomnessOutOfRange => "randomness is too large",
};
write!(f, "{message}")
}
}