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§
Sourcefn read(&self, key: &BackendKey) -> Result<Vec<u8>>
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.
Sourcefn write(&self, key: &BackendKey, data: &[u8]) -> Result<()>
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.
Sourcefn delete(&self, key: &BackendKey) -> Result<()>
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.
Provided Methods§
Sourcefn exists(&self, key: &BackendKey) -> Result<bool>
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.