trelent_hyok/error/mod.rs
1//! Error types used throughout the DEK management system.
2//!
3//! This module provides a comprehensive error handling system for the DEK library,
4//! encompassing all possible error conditions that may arise during DEK operations.
5//! It includes errors for caching, encryption, key generation, and CMK operations.
6
7pub mod cache;
8pub mod cmk;
9pub mod encryption;
10pub mod generator;
11
12/// Represents all possible errors that may occur when working with DEKs.
13///
14/// This enum serves as the top-level error type for the DEK library,
15/// encompassing all possible error conditions:
16/// - Cache-related errors (storage, retrieval)
17/// - Encryption/decryption errors
18/// - Key generation errors
19/// - CMK-related errors
20/// - General operational errors
21#[derive(Debug)]
22pub enum DEKError {
23 /// Errors related to DEK caching operations
24 CacheError(cache::CacheError),
25 /// Errors related to encryption/decryption operations
26 EncryptionError(encryption::EncryptionError),
27 /// Errors related to DEK generation
28 GeneratorError(generator::GeneratorError),
29 /// Errors related to Customer Managed Key operations
30 CmkError(cmk::CMKError),
31 /// General operational errors
32 GeneralError(GeneralError),
33}
34
35use core::fmt;
36
37/// Represents a more general error in the DEK library.
38///
39/// This error type is used for operational errors that don't fit into
40/// more specific categories, such as:
41/// - Configuration errors
42/// - System-level issues
43/// - Unexpected conditions
44#[derive(Debug, Eq, PartialEq)]
45pub struct GeneralError(pub String);
46
47impl fmt::Display for GeneralError {
48 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
49 write!(f, "Error fetching CMK token: {}", self.0)
50 }
51}