Skip to main content

KeyStore

Trait KeyStore 

Source
pub trait KeyStore {
    // Required methods
    fn describe(&self) -> String;
    fn get(&self, salt: &[u8; 16]) -> Result<Option<StoredSecret>>;
    fn put(
        &self,
        salt: &[u8; 16],
        secret: &StoredSecret,
        label: &str,
    ) -> Result<()>;
    fn delete(&self, salt: &[u8; 16]) -> Result<()>;

    // Provided methods
    fn durable(&self) -> bool { ... }
    fn check_available(&self) -> Result<()> { ... }
}
Expand description

Where brains’ secrets are kept, each found by its brain’s salt: the OS keychain (the keychain feature), or the test store.

Required Methods§

Source

fn describe(&self) -> String

How to name it to a person (“the test key store at …”).

Source

fn get(&self, salt: &[u8; 16]) -> Result<Option<StoredSecret>>

The entry for salt, if there is one.

Source

fn put(&self, salt: &[u8; 16], secret: &StoredSecret, label: &str) -> Result<()>

Store secret under salt, replacing any entry. label is for a person browsing the store (the brain’s path); nothing looks it up.

Source

fn delete(&self, salt: &[u8; 16]) -> Result<()>

Remove the entry for salt, if there is one.

Provided Methods§

Source

fn durable(&self) -> bool

Whether an entry is known to be on disk when KeyStore::put returns. None of the OS stores documents it, so the default is false, and the keys note’s section 4 rule applies: a new key the display rule can’t show isn’t left in the store alone.

Source

fn check_available(&self) -> Result<()>

Whether the store can be used here at all: an error says why not (no Secret Service on the session bus, no access). It reads one entry that never exists, so it asks nothing of the user.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§