pub struct JsonCrdt { /* private fields */ }Expand description
Collaborative JSON document CRDT.
Provides Automerge-like semantics for editing nested JSON structures with conflict-free concurrent operations.
Implementations§
Source§impl JsonCrdt
impl JsonCrdt
Sourcepub fn replica_id(&self) -> &str
pub fn replica_id(&self) -> &str
Get the replica ID.
Sourcepub fn set(&mut self, path: &JsonPath, value: JsonValue) -> Result<(), DbError>
pub fn set(&mut self, path: &JsonPath, value: JsonValue) -> Result<(), DbError>
Set a value at a path.
Sourcepub fn create_object(&mut self) -> ObjectId
pub fn create_object(&mut self) -> ObjectId
Create a new object and return its ID.
Sourcepub fn create_array(&mut self) -> ArrayId
pub fn create_array(&mut self) -> ArrayId
Create a new array and return its ID.
Sourcepub fn set_object(&mut self, path: &JsonPath) -> Result<ObjectId, DbError>
pub fn set_object(&mut self, path: &JsonPath) -> Result<ObjectId, DbError>
Set a nested object at a path.
Sourcepub fn set_array(&mut self, path: &JsonPath) -> Result<ArrayId, DbError>
pub fn set_array(&mut self, path: &JsonPath) -> Result<ArrayId, DbError>
Set a nested array at a path.
Sourcepub fn array_insert(
&mut self,
array_id: &ArrayId,
index: usize,
value: JsonValue,
) -> Result<(), DbError>
pub fn array_insert( &mut self, array_id: &ArrayId, index: usize, value: JsonValue, ) -> Result<(), DbError>
Insert into an array.
Sourcepub fn array_push(
&mut self,
array_id: &ArrayId,
value: JsonValue,
) -> Result<(), DbError>
pub fn array_push( &mut self, array_id: &ArrayId, value: JsonValue, ) -> Result<(), DbError>
Push to an array.
Sourcepub fn array_remove(
&mut self,
array_id: &ArrayId,
index: usize,
) -> Result<JsonValue, DbError>
pub fn array_remove( &mut self, array_id: &ArrayId, index: usize, ) -> Result<JsonValue, DbError>
Remove from an array.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Check if a key exists in the root object.
Sourcepub fn take_delta(&mut self) -> Option<JsonCrdtDelta>
pub fn take_delta(&mut self) -> Option<JsonCrdtDelta>
Take the pending delta.
Sourcepub fn apply_delta(&mut self, delta: &JsonCrdtDelta)
pub fn apply_delta(&mut self, delta: &JsonCrdtDelta)
Apply a delta from another replica.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for JsonCrdt
impl<'de> Deserialize<'de> for JsonCrdt
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Lattice for JsonCrdt
impl Lattice for JsonCrdt
Source§fn join(&self, other: &Self) -> Self
fn join(&self, other: &Self) -> Self
Join operation (least upper bound)
Must be commutative, associative, and idempotent
Source§fn partial_cmp_lattice(&self, other: &Self) -> Option<Ordering>
fn partial_cmp_lattice(&self, other: &Self) -> Option<Ordering>
Partial order derived from join: a ≤ b iff a ⊔ b = b
Source§fn join_assign(&mut self, other: &Self)
fn join_assign(&mut self, other: &Self)
Join-assign: self = self ⊔ other
impl StructuralPartialEq for JsonCrdt
Auto Trait Implementations§
impl Freeze for JsonCrdt
impl RefUnwindSafe for JsonCrdt
impl Send for JsonCrdt
impl Sync for JsonCrdt
impl Unpin for JsonCrdt
impl UnwindSafe for JsonCrdt
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