#[derive(Debug, PartialEq, Eq, thiserror::Error)]
pub enum Error {
#[error("key missing (read_range/delete: get/stat signal absence with None)")]
Missing,
#[error("verification failed: content does not match key")]
Verification,
#[error("io: {0}")]
Io(String),
#[error("direct delete refused: key protected (nothing deleted)")]
GcRefuse,
#[error("invalid key bytes: truncated, unknown algorithm — rejects, never guesses")]
KeyInvalid,
#[error("token registry at its admission cap: mint refused, no token issued")]
RegistryFull,
}
#[cfg(test)]
mod tests {
use super::Error;
#[test]
fn each_variant_constructs() {
let variants: [Error; 6] = [
Error::Missing,
Error::Verification,
Error::Io("cursor closed mid-read".to_owned()),
Error::GcRefuse,
Error::KeyInvalid,
Error::RegistryFull,
];
let expected = [
"key missing",
"verification failed",
"io: cursor closed mid-read",
"direct delete refused",
"invalid key bytes",
"admission cap",
];
for (err, text) in variants.iter().zip(expected) {
assert!(err.to_string().contains(text), "{err:?}");
}
}
#[test]
fn one_enum_both_altitudes() {
let trait_effective: [Error; 4] = [
Error::Missing,
Error::Verification,
Error::Io("media".to_owned()),
Error::KeyInvalid,
];
assert_eq!(trait_effective.len(), 4);
let facade_surface: [Error; 6] = [
Error::Missing,
Error::Verification,
Error::Io("media".to_owned()),
Error::GcRefuse,
Error::KeyInvalid,
Error::RegistryFull,
];
assert_eq!(facade_surface.len(), 6);
}
}