pub struct RichTextDoc { /* private fields */ }Expand description
A collaborative rich text document with formatting.
Implementations§
Source§impl RichTextDoc
impl RichTextDoc
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 rich-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 format(&mut self, start: usize, end: usize, mark: MarkType)
pub fn format(&mut self, start: usize, end: usize, mark: MarkType)
Apply a formatting mark to the range [start, end).
Sourcepub fn unformat_by_id(&mut self, mark_id: &MarkId)
pub fn unformat_by_id(&mut self, mark_id: &MarkId)
Remove a formatting mark by its unique mark ID.
Sourcepub fn get_content(&self) -> String
pub fn get_content(&self) -> String
Return a plain-text rendering of the content.
For full mark spans and metadata, use the underlying RichText model.
Sourcepub fn merge(&mut self, other: &RichTextDoc)
pub fn merge(&mut self, other: &RichTextDoc)
Merge another replica state into this document.
This is a commutative CRDT join, so order does not affect convergence.
Sourcepub fn clone_state(&self) -> RichTextDoc
pub fn clone_state(&self) -> RichTextDoc
Clone this document’s state for synchronization.
The returned state clears local pending delta buffers.
Trait Implementations§
Source§impl Clone for RichTextDoc
impl Clone for RichTextDoc
Source§fn clone(&self) -> RichTextDoc
fn clone(&self) -> RichTextDoc
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl CollaborativeDoc for RichTextDoc
impl CollaborativeDoc for RichTextDoc
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 RichTextDoc
impl !RefUnwindSafe for RichTextDoc
impl Send for RichTextDoc
impl Sync for RichTextDoc
impl Unpin for RichTextDoc
impl UnsafeUnpin for RichTextDoc
impl !UnwindSafe for RichTextDoc
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