Skip to main content

CrdtStore

Struct CrdtStore 

Source
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

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn contains<E: KvEngine>( &self, engine: &E, doc_id: &str, ) -> CrdtResult<bool>

Whether a document has been persisted under doc_id.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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.
Source§

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

Source§

fn vzip(self) -> V