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 related to encryption and decryption operations.
//!
//! This module provides error types that may occur during data encryption
//! and decryption operations, including key validation, algorithm-specific
//! errors, and data formatting issues.

use core::fmt;
use std::fmt::Debug;

/// Represents an error encountered during encryption or decryption operations.
///
/// This error type is used when encryption-related operations fail, such as:
/// - Invalid key size or format
/// - Algorithm-specific failures
/// - Data padding issues
/// - Authentication failures
#[derive(Debug, Eq, PartialEq)]
pub struct EncryptionError(pub String);

impl EncryptionError {
    /// Creates a new encryption error with the specified message.
    ///
    /// # Arguments
    /// * `message` - A description of the error that occurred
    pub fn new(message: String) -> Self {
        Self(message)
    }
}

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