Skip to main content

KeyringStore

Trait KeyringStore 

Source
pub trait KeyringStore: Send + Sync {
    // Required methods
    fn get(&self, key: &str) -> Result<Option<String>, SecretsError>;
    fn set(&self, key: &str, value: &str) -> Result<(), SecretsError>;
    fn delete(&self, key: &str) -> Result<(), SecretsError>;
    fn backend_name(&self) -> &'static str;
}
Expand description

Abstract secret store trait.

Concrete implementations may use the OS keyring (DefaultKeyringStore), a JSON file under ~/.codewhale/secrets/ (FileKeyringStore), or an in-memory map for tests (InMemoryKeyringStore).

All implementations must be Send + Sync so they can be shared across threads via Arc.

Required Methods§

Source

fn get(&self, key: &str) -> Result<Option<String>, SecretsError>

Read a secret by key.

Returns Ok(None) if no entry exists for the given key. Returns Err only on backend failures (I/O errors, keyring access issues).

Source

fn set(&self, key: &str, value: &str) -> Result<(), SecretsError>

Write a secret, replacing any existing value for the same key.

Creates the backing store (e.g. the JSON file) on first write if it does not yet exist.

Source

fn delete(&self, key: &str) -> Result<(), SecretsError>

Remove a secret by key.

Implementations should succeed (no-op) if the entry is already absent rather than returning an error.

Source

fn backend_name(&self) -> &'static str

Short, human-readable label for this backend.

Used by diagnostic output (e.g. doctor command) to indicate which storage backend is active. Examples: "file-based (~/.codewhale/secrets/)", "system keyring", "in-memory (test)".

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§