pub struct JsonDoc { /* private fields */ }Expand description
A collaborative JSON document.
Implementations§
Source§impl JsonDoc
impl JsonDoc
Sourcepub fn new(id: impl Into<String>, replica_id: impl Into<String>) -> Self
pub fn new(id: impl Into<String>, replica_id: impl Into<String>) -> Self
Create a new JSON CRDT document.
Sourcepub fn set(&mut self, path: &str, value: JsonValue)
pub fn set(&mut self, path: &str, value: JsonValue)
Set a value at a dot-path (for example, "profile.name").
Sourcepub fn merge(&mut self, other: &JsonDoc)
pub fn merge(&mut self, other: &JsonDoc)
Merge another replica state into this document.
This is a commutative CRDT join, so order does not affect convergence.
Sourcepub fn clone_state(&self) -> JsonDoc
pub fn clone_state(&self) -> JsonDoc
Clone this document’s state for synchronization.
The returned state clears local pending delta buffers.
Trait Implementations§
Source§impl CollaborativeDoc for JsonDoc
impl CollaborativeDoc for JsonDoc
Source§fn replica_id(&self) -> &str
fn replica_id(&self) -> &str
Return the local replica identifier that owns this document handle.
Source§fn take_pending_deltas(&mut self) -> Vec<Vec<u8>>
fn take_pending_deltas(&mut self) -> Vec<Vec<u8>>
Drain pending deltas to send through your sync transport.
Source§fn apply_remote(&mut self, _delta: &[u8])
fn apply_remote(&mut self, _delta: &[u8])
Apply a serialized remote delta payload.
Auto Trait Implementations§
impl Freeze for JsonDoc
impl !RefUnwindSafe for JsonDoc
impl Send for JsonDoc
impl Sync for JsonDoc
impl Unpin for JsonDoc
impl UnsafeUnpin for JsonDoc
impl !UnwindSafe for JsonDoc
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