Skip to main content

AsyncBlobStore

Trait AsyncBlobStore 

Source
pub trait AsyncBlobStore:
    Debug
    + Send
    + Sync {
    // Required methods
    fn read_blob(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, String>> + Send + '_>>;
    fn write_blob(
        &self,
        bytes: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + '_>>;
}
Expand description

[CR-4] re-export so hosts can build ClientConfig { storage_backend: … } without pulling ping_mls_store in directly. AsyncBlobStore is the async single-blob trait WASM hosts implement to back StorageBackend::IndexedDb; BlobFuture is the matching future-type helper. Async single-blob storage. Reads + writes the entire MLS snapshot as one opaque byte slab; the provider takes care of (de)serialising the MemoryStorage HashMap inside that slab.

Native targets get Send + Sync so the provider can be shared across tokio threads; WASM drops the bound to match wasm-bindgen + JsFuture being !Send.

Debug is required so crate::StorageBackend can still derive Debug without resorting to a manual impl on the enum.

Required Methods§

Source

fn read_blob( &self, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, String>> + Send + '_>>

Return the previously-written snapshot, or Ok(None) when the store is empty. Errors propagate as String so we don’t have to pull the host’s error type into this crate.

Source

fn write_blob( &self, bytes: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + '_>>

Overwrite the snapshot. Implementations MUST be atomic (a partial write would leave the provider unable to load on next cold start).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§