Skip to main content

CrdtDoc

Struct CrdtDoc 

Source
pub struct CrdtDoc { /* private fields */ }
Expand description

CRDT document wrapping a Yjs Doc for conflict-free merging.

Implementations§

Source§

impl CrdtDoc

Source

pub fn from_text(content: &str) -> Self

Create a new CRDT document initialized with the given text content.

Source

pub fn to_text(&self) -> String

Extract the current text content from the CRDT document.

Source

pub fn apply_edit(&self, offset: u32, delete_len: u32, insert: &str)

Apply a local edit: delete delete_len chars at offset, then insert insert there.

Source

pub fn encode_state(&self) -> Vec<u8>

Encode the full document state (for persistence).

Source

pub fn decode_state(bytes: &[u8]) -> Result<Self>

Decode a previously encoded state into a new CrdtDoc.

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.