trelent-hyok 0.1.12

A Rust library implementing Hold Your Own Key (HYOK) encryption patterns with support for multiple cloud providers
Documentation
//! Error types used throughout the DEK management system.
//!
//! This module provides a comprehensive error handling system for the DEK library,
//! encompassing all possible error conditions that may arise during DEK operations.
//! It includes errors for caching, encryption, key generation, and CMK operations.

pub mod cache;
pub mod cmk;
pub mod encryption;
pub mod generator;

/// Represents all possible errors that may occur when working with DEKs.
///
/// This enum serves as the top-level error type for the DEK library,
/// encompassing all possible error conditions:
/// - Cache-related errors (storage, retrieval)
/// - Encryption/decryption errors
/// - Key generation errors
/// - CMK-related errors
/// - General operational errors
#[derive(Debug)]
pub enum DEKError {
    /// Errors related to DEK caching operations
    CacheError(cache::CacheError),
    /// Errors related to encryption/decryption operations
    EncryptionError(encryption::EncryptionError),
    /// Errors related to DEK generation
    GeneratorError(generator::GeneratorError),
    /// Errors related to Customer Managed Key operations
    CmkError(cmk::CMKError),
    /// General operational errors
    GeneralError(GeneralError),
}

use core::fmt;

/// Represents a more general error in the DEK library.
///
/// This error type is used for operational errors that don't fit into
/// more specific categories, such as:
/// - Configuration errors
/// - System-level issues
/// - Unexpected conditions
#[derive(Debug, Eq, PartialEq)]
pub struct GeneralError(pub String);

impl fmt::Display for GeneralError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "Error fetching CMK token: {}", self.0)
    }
}