Skip to main content

KeyProvider

Trait KeyProvider 

Source
pub trait KeyProvider:
    Send
    + Sync
    + Debug {
    // Required methods
    fn current_key(&self) -> Result<(SecretKey, String), AuthError>;
    fn key_by_id(&self, key_id: &str) -> Result<SecretKey, AuthError>;
    fn key_ids(&self) -> Vec<String>;
}
Expand description

Trait for providing encryption keys.

Implementations can load keys from files, environment variables, or external KMS services.

All key material is returned as SecretKey to ensure automatic zeroization when the consumer drops the value.

Required Methods§

Source

fn current_key(&self) -> Result<(SecretKey, String), AuthError>

Get the current (latest) encryption key and its ID.

Source

fn key_by_id(&self, key_id: &str) -> Result<SecretKey, AuthError>

Get a key by its ID (for decrypting old data).

Source

fn key_ids(&self) -> Vec<String>

List all available key IDs.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§