use core::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum MoidError {
EmptyAlphabet,
AlphabetTooLarge,
NonAsciiAlphabet,
DuplicateSymbol,
BadLength,
BadChar,
BadCheck,
BadPrefix,
PrefixOutOfAlphabet,
#[cfg(feature = "os")]
Entropy,
}
impl fmt::Display for MoidError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let msg = match self {
MoidError::EmptyAlphabet => "alphabet is empty",
MoidError::AlphabetTooLarge => "alphabet has more than 255 symbols",
MoidError::NonAsciiAlphabet => "alphabet contains a non-ASCII symbol",
MoidError::DuplicateSymbol => "alphabet contains a duplicate symbol",
MoidError::BadLength => "id has an invalid length",
MoidError::BadChar => "id contains a character outside the alphabet",
MoidError::BadCheck => "id check character does not match",
MoidError::BadPrefix => "id is missing the expected prefix",
MoidError::PrefixOutOfAlphabet => "prefix contains a character outside the alphabet",
#[cfg(feature = "os")]
MoidError::Entropy => "the OS entropy source failed",
};
f.write_str(msg)
}
}
#[cfg(feature = "std")]
impl std::error::Error for MoidError {}