revault_vault_api 0.0.6

reVault API for creating and managing vaults
Documentation
use revault_lockbox_api::{LockboxId, Result, SecretVec};
use std::path::Path;

/// Storage backend for opened Lockbox content keys.
///
/// `Vault` uses this trait to cache content keys after a lockbox is created or
/// opened, and to retrieve them for later cache-only opens. Implementations
/// may keep keys in memory, forward them to a local agent, or deliberately
/// discard them.
pub trait ContentKeyStore {
    /// Returns the cached content key for `lockbox_id`, if one is available.
    fn get_content_key(&self, lockbox_id: LockboxId) -> Result<Option<SecretVec>>;

    /// Stores the opened content key for `lockbox_id`.
    fn put_content_key(&self, lockbox_id: LockboxId, key: SecretVec) -> Result<()>;

    /// Stores the opened content key with a display path for diagnostics.
    fn put_content_key_for_path(
        &self,
        lockbox_id: LockboxId,
        key: SecretVec,
        _path: &Path,
    ) -> Result<()> {
        self.put_content_key(lockbox_id, key)
    }

    /// Stores the opened content key with an explicit cache lifetime.
    fn put_content_key_for_path_with_ttl(
        &self,
        lockbox_id: LockboxId,
        key: SecretVec,
        path: &Path,
        _ttl_seconds: u64,
    ) -> Result<()> {
        self.put_content_key_for_path(lockbox_id, key, path)
    }

    /// Removes the cached content key for `lockbox_id`.
    fn forget_content_key(&self, lockbox_id: LockboxId) -> Result<()>;

    /// Removes all cached content keys known to this store.
    fn forget_all_content_keys(&self) -> Result<()>;
}