Skip to main content

KeychainBackend

Trait KeychainBackend 

Source
pub trait KeychainBackend:
    Send
    + Sync
    + 'static {
    // Required methods
    fn read(&self, key: &BackendKey) -> Result<Vec<u8>>;
    fn write(&self, key: &BackendKey, data: &[u8]) -> Result<()>;
    fn delete(&self, key: &BackendKey) -> Result<()>;
    fn list(&self, prefix: &str) -> Result<Vec<BackendKey>>;

    // Provided method
    fn exists(&self, key: &BackendKey) -> Result<bool> { ... }
}
Expand description

Storage backend trait. Implementations must be Send + Sync + 'static so they can be held behind Arc<dyn KeychainBackend>.

Required Methods§

Source

fn read(&self, key: &BackendKey) -> Result<Vec<u8>>

Read the full contents of the blob at key.

Returns a backend I/O error if the blob does not exist.

Source

fn write(&self, key: &BackendKey, data: &[u8]) -> Result<()>

Write data to key. Implementations should be atomic — a reader seeing the key after this call must see either the old bytes or the new bytes in full, never a torn mix.

Source

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

Remove the blob at key. Implementations should best-effort overwrite the storage before removing so residual disk sectors do not retain the ciphertext.

Source

fn list(&self, prefix: &str) -> Result<Vec<BackendKey>>

List keys that start with prefix. Order is unspecified.

Provided Methods§

Source

fn exists(&self, key: &BackendKey) -> Result<bool>

Whether a blob exists at key. Default impl delegates to read; backends with cheaper existence checks should override.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§