Skip to main content

KeyProvider

Trait KeyProvider 

Source
pub trait KeyProvider: Send + Sync {
    // Required method
    fn load_keys(&self) -> Result<LoadedKeys>;
}
Expand description

Supplies the encryption key(s) StorageEncryption uses.

Exists as a seam so the key source (env var today) can be swapped for a KMS or an age/sops-style file-based secret without touching StorageEncryption or EncryptedStorage at all. See EnvKeyProvider’s own docs for the current, deliberately narrow, implementation and its known limitation.

Required Methods§

Source

fn load_keys(&self) -> Result<LoadedKeys>

Load every key this provider knows about, keyed by key id, plus which one is current (new writes use this one; any key in the map can still be used to decrypt an old envelope that names it).

Returns an error if no usable key can be loaded at all – callers must fail closed on that, never silently fall back to no encryption.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§