pub struct CrdtStore { /* private fields */ }Expand description
Persists CrdtDocs into an encrypted spacedb-store collection. Engine-
agnostic like the underlying Collection: the methods take the engine and
open their own transactions.
Implementations§
Source§impl CrdtStore
impl CrdtStore
Sourcepub fn open<E: KvEngine>(
engine: &E,
key_provider: Arc<dyn KeyProvider>,
) -> CrdtResult<Self>
pub fn open<E: KvEngine>( engine: &E, key_provider: Arc<dyn KeyProvider>, ) -> CrdtResult<Self>
Open (or first-time provision) the CRDT document collection on engine.
Sourcepub fn save<E: KvEngine>(
&self,
engine: &E,
doc_id: &str,
doc: &CrdtDoc,
) -> CrdtResult<()>
pub fn save<E: KvEngine>( &self, engine: &E, doc_id: &str, doc: &CrdtDoc, ) -> CrdtResult<()>
Persist doc’s full CRDT state under doc_id, encrypted, in a single
write transaction.
Sourcepub fn load<E: KvEngine>(
&self,
engine: &E,
doc_id: &str,
actor_id: u64,
) -> CrdtResult<CrdtDoc>
pub fn load<E: KvEngine>( &self, engine: &E, doc_id: &str, actor_id: u64, ) -> CrdtResult<CrdtDoc>
Load the document stored under doc_id for replica actor_id. Returns a
fresh empty document if nothing has been persisted there yet (local-first:
you can always start writing).
Sourcepub fn apply_remote<E: KvEngine>(
&self,
engine: &E,
doc_id: &str,
actor_id: u64,
update: &[u8],
) -> CrdtResult<CrdtDoc>
pub fn apply_remote<E: KvEngine>( &self, engine: &E, doc_id: &str, actor_id: u64, update: &[u8], ) -> CrdtResult<CrdtDoc>
Receive side of anti-entropy: merge a remote update into the persisted
document and re-persist it (load → merge → save). Returns the merged doc.
Auto Trait Implementations§
impl !RefUnwindSafe for CrdtStore
impl !UnwindSafe for CrdtStore
impl Freeze for CrdtStore
impl Send for CrdtStore
impl Sync for CrdtStore
impl Unpin for CrdtStore
impl UnsafeUnpin for CrdtStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more