use thiserror::Error;
#[derive(Debug, Error, PartialEq, Eq)]
#[error("secure randomness unavailable")]
pub struct RandomError;
#[derive(Debug, Error, PartialEq, Eq)]
pub enum KeyError {
#[error("no active HMAC key configured")]
MissingActiveKey,
#[error("HMAC key version not available")]
MissingKeyVersion,
#[error("HMAC key material is invalid")]
InvalidKeyMaterial,
}
#[derive(Debug, Error, PartialEq, Eq)]
pub enum PolicyError {
#[error("alphabet must contain at least 2 symbols")]
AlphabetTooSmall,
#[error("alphabet contains duplicate symbols")]
AlphabetNotUnique,
#[error("alphabet contains an unsupported (non-ASCII) symbol")]
AlphabetNotAscii,
#[error("code length {got} is below the secure minimum of {min}")]
LengthBelowMinimum {
got: usize,
min: usize,
},
#[error("code length must be non-zero")]
ZeroLength,
}
#[derive(Debug, Error, PartialEq, Eq)]
pub enum CodeInputError {
#[error("code input is empty")]
Empty,
#[error("code input exceeds maximum raw length")]
TooLongRaw,
#[error("normalized code length does not match policy")]
WrongLength,
#[error("code input contains unsupported characters")]
UnsupportedCharacters,
}