pub struct TextDoc { /* private fields */ }Expand description
A collaborative plain text document.
Implementations§
Source§impl TextDoc
impl TextDoc
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 plain-text CRDT document.
Sourcepub fn insert(&mut self, position: usize, text: &str)
pub fn insert(&mut self, position: usize, text: &str)
Insert UTF-8 text at a character position.
Sourcepub fn delete(&mut self, position: usize, length: usize)
pub fn delete(&mut self, position: usize, length: usize)
Delete length characters starting at position.
Sourcepub fn merge(&mut self, other: &TextDoc)
pub fn merge(&mut self, other: &TextDoc)
Merge another replica state into this document.
This is a commutative CRDT join, so order does not affect convergence.
Sourcepub fn clone_state(&self) -> TextDoc
pub fn clone_state(&self) -> TextDoc
Clone this document’s state for synchronization.
The returned state clears local pending delta buffers.
Trait Implementations§
Source§impl CollaborativeDoc for TextDoc
impl CollaborativeDoc for TextDoc
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 TextDoc
impl !RefUnwindSafe for TextDoc
impl Send for TextDoc
impl Sync for TextDoc
impl Unpin for TextDoc
impl UnsafeUnpin for TextDoc
impl !UnwindSafe for TextDoc
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