use std::fmt;
#[derive(Debug)]
pub enum HexvaultError {
InvalidKey,
EncryptionFailure,
DecryptionFailure,
KeyDerivationFailure,
RandomnessFailure,
CellNotFound(String),
CellAlreadyExists(String),
InvalidLayer,
MissingOrInvalidContext,
InvalidTraversal(String),
InvalidCellId,
InvalidPartitionId,
}
impl fmt::Display for HexvaultError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidKey => write!(f, "invalid key"),
Self::EncryptionFailure => write!(f, "encryption failed"),
Self::DecryptionFailure => write!(f, "decryption failed"),
Self::KeyDerivationFailure => write!(f, "key derivation failed"),
Self::RandomnessFailure => write!(f, "randomness source failed"),
Self::CellNotFound(id) => write!(f, "cell not found: {}", id),
Self::CellAlreadyExists(id) => write!(f, "cell already exists: {}", id),
Self::InvalidLayer => write!(f, "invalid layer"),
Self::MissingOrInvalidContext => write!(f, "missing or invalid layer context"),
Self::InvalidTraversal(reason) => write!(f, "invalid traversal: {}", reason),
Self::InvalidCellId => write!(f, "cell ID must not be empty"),
Self::InvalidPartitionId => write!(f, "partition ID must not be empty"),
}
}
}
impl std::error::Error for HexvaultError {}