use core::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum OrionIdError {
InvalidLength,
InvalidCharacter,
InvalidOption(&'static str),
TimestampOverflow,
CounterOverflow,
RandomFailure,
}
impl fmt::Display for OrionIdError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidLength => f.write_str("ORION-192 id must be 32 characters"),
Self::InvalidCharacter => {
f.write_str("ORION-192 id contains a character outside the sortable64 alphabet")
}
Self::InvalidOption(name) => write!(f, "invalid option: {name}"),
Self::TimestampOverflow => {
f.write_str("ORION-192 timestamp overflow: choose a later epoch_ms")
}
Self::CounterOverflow => f.write_str("ORION-192 counter overflow"),
Self::RandomFailure => f.write_str("operating-system CSPRNG failed"),
}
}
}
impl std::error::Error for OrionIdError {}