EncryptedSyncStorage

Struct EncryptedSyncStorage 

Source
pub struct EncryptedSyncStorage { /* private fields */ }
Expand description

SyncStorage that delegates raw I/O to a CloudHome and handles the path layout and encryption layer.

Implementations§

Source§

impl EncryptedSyncStorage

Source

pub fn new(home: Box<dyn CloudHome>, encryption: EncryptionService) -> Self

Source

pub fn shared_encryption(&self) -> Arc<RwLock<EncryptionService>>

Return a shared reference to the encryption lock for external use (e.g., SyncHandle can share the same instance for snapshot creation).

Source

pub fn cloud_home(&self) -> &dyn CloudHome

Borrow the underlying CloudHome for direct access (e.g., grant_access/revoke_access).

Source

pub fn blob_key(namespace: &str, id: &str) -> String

Blob key: {namespace}/{ab}/{cd}/{id}.

Trait Implementations§

Source§

impl SyncStorage for EncryptedSyncStorage

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. Read more
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. Read more
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. Read more
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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more