SyncStorage

Trait SyncStorage 

Source
pub trait SyncStorage: Send + Sync {
Show 20 methods // Required methods fn list_heads<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<DeviceHead>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_changeset<'life0, 'life1, 'async_trait>( &'life0 self, device_id: &'life1 str, seq: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn put_changeset<'life0, 'life1, 'async_trait>( &'life0 self, device_id: &'life1 str, seq: u64, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn put_head<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, device_id: &'life1 str, seq: u64, snapshot_seq: Option<u64>, timestamp: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn put_blob<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, namespace: &'life1 str, id: &'life2 str, scope: BlobScope, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn get_blob<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, namespace: &'life1 str, id: &'life2 str, scope: BlobScope, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn put_snapshot<'life0, 'async_trait>( &'life0 self, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_snapshot<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn delete_changeset<'life0, 'life1, 'async_trait>( &'life0 self, device_id: &'life1 str, seq: u64, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn list_changesets<'life0, 'life1, 'async_trait>( &'life0 self, device_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u64>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_min_schema_version<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<u32>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_min_schema_version<'life0, 'async_trait>( &'life0 self, version: u32, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn put_membership_entry<'life0, 'life1, 'async_trait>( &'life0 self, author_pubkey: &'life1 str, seq: u64, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_membership_entry<'life0, 'life1, 'async_trait>( &'life0 self, author_pubkey: &'life1 str, seq: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn list_membership_entries<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, u64)>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn put_wrapped_key<'life0, 'life1, 'async_trait>( &'life0 self, user_pubkey: &'life1 str, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_wrapped_key<'life0, 'life1, 'async_trait>( &'life0 self, user_pubkey: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn delete_wrapped_key<'life0, 'life1, 'async_trait>( &'life0 self, user_pubkey: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn put_snapshot_meta<'life0, 'async_trait>( &'life0 self, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_snapshot_meta<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}

Required Methods§

Source

fn list_heads<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<DeviceHead>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List all device heads (one LIST call to heads/).

Source

fn get_changeset<'life0, 'life1, 'async_trait>( &'life0 self, device_id: &'life1 str, seq: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch a single changeset by device_id and seq.

Returns the decrypted envelope bytes from changes/{device_id}/{seq}.enc. Implementations must handle downloading the encrypted blob and decrypting it before returning. Callers receive plaintext ready for envelope::unpack().

Source

fn put_changeset<'life0, 'life1, 'async_trait>( &'life0 self, device_id: &'life1 str, seq: u64, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Upload a changeset blob (plaintext — the implementation encrypts it). Writes to changes/{device_id}/{seq}.enc.

Source

fn put_head<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, device_id: &'life1 str, seq: u64, snapshot_seq: Option<u64>, timestamp: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Update the head pointer for a device. Writes to heads/{device_id}.json.enc. If snapshot_seq is Some, the head records that a snapshot covers all changesets up to that seq. timestamp is the RFC 3339 time of this sync (used by the sync status UI).

Source

fn put_blob<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, namespace: &'life1 str, id: &'life2 str, scope: BlobScope, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Upload an encrypted blob to {namespace}/{id[0..2]}/{id[2..4]}/{id}. The plaintext is encrypted with the key selected by scope (master, or a per-scope derived key).

Source

fn get_blob<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, namespace: &'life1 str, id: &'life2 str, scope: BlobScope, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Download and decrypt a blob from {namespace}/{id[0..2]}/{id[2..4]}/{id}, using the key selected by scope.

Source

fn put_snapshot<'life0, 'async_trait>( &'life0 self, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Upload an encrypted snapshot. Writes to snapshot.db.enc (overwrites any previous snapshot).

Source

fn get_snapshot<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Download the encrypted snapshot. Returns bytes from snapshot.db.enc.

Source

fn delete_changeset<'life0, 'life1, 'async_trait>( &'life0 self, device_id: &'life1 str, seq: u64, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a single changeset from storage. Removes changes/{device_id}/{seq}.enc.

Source

fn list_changesets<'life0, 'life1, 'async_trait>( &'life0 self, device_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u64>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all changeset keys for a device. Returns the sequence numbers that exist in changes/{device_id}/.

Source

fn get_min_schema_version<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<u32>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the minimum schema version required to sync with this storage.

Returns None if no minimum has been set (backwards compat: any version can sync). Reads from min_schema_version.json.enc.

Source

fn set_min_schema_version<'life0, 'async_trait>( &'life0 self, version: u32, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the minimum schema version required to sync with this storage.

Writes to min_schema_version.json.enc. Used when a breaking migration bumps the schema and all devices must upgrade before syncing.

Source

fn put_membership_entry<'life0, 'life1, 'async_trait>( &'life0 self, author_pubkey: &'life1 str, seq: u64, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Upload a membership entry. Writes to membership/{author_pubkey_hex}/{seq}.enc.

Source

fn get_membership_entry<'life0, 'life1, 'async_trait>( &'life0 self, author_pubkey: &'life1 str, seq: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Download a membership entry. Reads from membership/{author_pubkey_hex}/{seq}.enc.

Source

fn list_membership_entries<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, u64)>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List all membership entry keys. Returns tuples of (author_pubkey, seq).

Source

fn put_wrapped_key<'life0, 'life1, 'async_trait>( &'life0 self, user_pubkey: &'life1 str, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Upload a wrapped library key for a member. Writes to keys/{user_pubkey_hex}.enc.

Source

fn get_wrapped_key<'life0, 'life1, 'async_trait>( &'life0 self, user_pubkey: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Download a wrapped library key for a member. Reads from keys/{user_pubkey_hex}.enc.

Source

fn delete_wrapped_key<'life0, 'life1, 'async_trait>( &'life0 self, user_pubkey: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a wrapped library key. Removes keys/{user_pubkey_hex}.enc.

Source

fn put_snapshot_meta<'life0, 'async_trait>( &'life0 self, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Upload snapshot metadata (plaintext – the implementation encrypts it). Writes to snapshot_meta.json.enc.

Source

fn get_snapshot_meta<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Download snapshot metadata (decrypted). Reads from snapshot_meta.json.enc. Returns NotFound if no metadata exists.

Implementors§