pub struct RGAText { /* private fields */ }Expand description
Collaborative text CRDT using RGA algorithm.
Supports character-level insert and delete with deterministic conflict resolution.
Implementations§
Source§impl RGAText
impl RGAText
Sourcepub fn replica_id(&self) -> &str
pub fn replica_id(&self) -> &str
Get the replica ID.
Sourcepub fn delete(&mut self, start: usize, length: usize)
pub fn delete(&mut self, start: usize, length: usize)
Delete characters from start to start+length.
Sourcepub fn splice(&mut self, position: usize, delete_count: usize, insert: &str)
pub fn splice(&mut self, position: usize, delete_count: usize, insert: &str)
Splice: delete some characters and insert new ones.
Sourcepub fn id_to_position(&self, id: &TextId) -> Option<usize>
pub fn id_to_position(&self, id: &TextId) -> Option<usize>
Convert a TextId to a visible position.
Sourcepub fn position_to_id(&self, position: usize) -> Option<TextId>
pub fn position_to_id(&self, position: usize) -> Option<TextId>
Convert a visible position to a TextId.
Sourcepub fn take_delta(&mut self) -> Option<RGATextDelta>
pub fn take_delta(&mut self) -> Option<RGATextDelta>
Take the pending delta.
Sourcepub fn apply_delta(&mut self, delta: &RGATextDelta)
pub fn apply_delta(&mut self, delta: &RGATextDelta)
Apply a delta from another replica.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RGAText
impl<'de> Deserialize<'de> for RGAText
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 RGAText
impl Lattice for RGAText
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 Eq for RGAText
Auto Trait Implementations§
impl Freeze for RGAText
impl RefUnwindSafe for RGAText
impl Send for RGAText
impl Sync for RGAText
impl Unpin for RGAText
impl UnwindSafe for RGAText
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