Skip to main content

LeafStore

Trait LeafStore 

Source
pub trait LeafStore: Send + Sync {
    // Required methods
    fn store(
        &self,
        key_type: &str,
        key_id: &str,
        data: &[u8],
    ) -> Result<(), StoreError>;
    fn load(
        &self,
        key_type: &str,
        key_id: &str,
    ) -> Result<Option<Vec<u8>>, StoreError>;
    fn delete(&self, key_type: &str, key_id: &str) -> Result<(), StoreError>;
}
Expand description

Durable storage for a leaf node’s secret material and MLS state.

The shape mirrors MlsStorage in offline-protocol-mls, which is the same seam on the phone: a two-part (key_type, key_id) key, &self methods so one store can be shared by the several places that write through it, and per-entry atomicity. A device implements it over the part’s secure key storage, its flash filesystem, or an EEPROM.

§Errors

Returning an error is always safe. It aborts the operation before anything is emitted, which is the whole point of the seam.

Required Methods§

Source

fn store( &self, key_type: &str, key_id: &str, data: &[u8], ) -> Result<(), StoreError>

Writes data, replacing any previous value for this key.

Must be durable and atomic per entry: after Ok, a power cut leaves either the new value or the old one, never a torn record, and a subsequent LeafStore::load returns the new value.

Source

fn load( &self, key_type: &str, key_id: &str, ) -> Result<Option<Vec<u8>>, StoreError>

Reads a value, or None if this key was never written.

Source

fn delete(&self, key_type: &str, key_id: &str) -> Result<(), StoreError>

Removes a value. Removing a key that is not there is not an error.

Every value this crate stores is secret, so an implementation should erase rather than unlink.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§