use alloc::string::String;
use thiserror::Error;
#[derive(Clone, Debug, Eq, PartialEq, Error)]
#[non_exhaustive]
pub enum AeadSealError {
#[error("verifier-mode seal has no master key")]
NoMasterKey,
#[error("card `{0}` is not in the deck")]
CardNotInDeck(String),
#[error("unseal failed: bad token, wrong slot, or wrong context")]
Unseal,
#[error("authentic payload decoded to ordinal {0}, which is out of range")]
InvalidOrdinal(u16),
#[error("deck name of {0} bytes exceeds the 65535 the associated data can describe")]
DeckNameTooLong(usize),
#[error("pile of {0} cards exceeds the 65535 slots a SlotPile can name")]
PileTooLong(usize),
}
#[cfg(test)]
#[allow(non_snake_case)]
mod seal__aead__error_tests {
use super::*;
use alloc::string::ToString;
#[test]
fn display__all_variants() {
assert_eq!(
AeadSealError::NoMasterKey.to_string(),
"verifier-mode seal has no master key"
);
assert_eq!(
AeadSealError::CardNotInDeck("A♠".to_string()).to_string(),
"card `A♠` is not in the deck"
);
assert_eq!(
AeadSealError::Unseal.to_string(),
"unseal failed: bad token, wrong slot, or wrong context"
);
assert_eq!(
AeadSealError::InvalidOrdinal(99).to_string(),
"authentic payload decoded to ordinal 99, which is out of range"
);
assert_eq!(
AeadSealError::PileTooLong(70_000).to_string(),
"pile of 70000 cards exceeds the 65535 slots a SlotPile can name"
);
assert_eq!(
AeadSealError::DeckNameTooLong(70_000).to_string(),
"deck name of 70000 bytes exceeds the 65535 the associated data can describe"
);
}
#[test]
fn error__is_std_error_send_sync() {
fn assert_bounds<E: core::error::Error + Send + Sync + 'static>() {}
assert_bounds::<AeadSealError>();
}
}