Skip to main content

KeychainBackend

Trait KeychainBackend 

Source
pub trait KeychainBackend: Send + Sync {
    // Required methods
    fn set(&mut self, profile_id: &str, secret: &Secret) -> Result<(), AppError>;
    fn get(&self, profile_id: &str) -> Result<Option<Secret>, AppError>;
    fn delete(&mut self, profile_id: &str) -> Result<(), AppError>;

    // Provided method
    fn unlock(&mut self, _passphrase: &str) -> Result<(), AppError> { ... }
}
Expand description

Backend-agnostic interface for persisting and retrieving credential secrets keyed by profile ID.

Required Methods§

Source

fn set(&mut self, profile_id: &str, secret: &Secret) -> Result<(), AppError>

Persist secret under profile_id, replacing any existing entry.

Source

fn get(&self, profile_id: &str) -> Result<Option<Secret>, AppError>

Retrieve the secret for profile_id, or None if not present.

Source

fn delete(&mut self, profile_id: &str) -> Result<(), AppError>

Remove the secret for profile_id. No-op if it does not exist.

Provided Methods§

Source

fn unlock(&mut self, _passphrase: &str) -> Result<(), AppError>

Supply a passphrase to unlock a passphrase-protected backend.

For backends that do not require a passphrase (e.g. KeyringBackend, StubBackend) this is a no-op that always returns Ok(()).

FileBackend overrides this to re-derive the encryption key from the supplied passphrase and attempt to decrypt the secrets file.

Called by keychain_fallback_unlock in response to the user submitting the KeychainFallbackPrompt in the Credential Manager UI.

Implementors§