pub struct RGAList<T: Clone + PartialEq> {
nodes: HashMap<ListId, ListNode<T>>,
children: HashMap<ListId, Vec<ListId>>,
replica_id: String,
seq: u64,
pending_delta: Option<RGAListDelta<T>>,
}Expand description
Replicated Growable Array - an ordered list CRDT.
Supports insert, delete, and move operations with deterministic conflict resolution.
Fields§
§nodes: HashMap<ListId, ListNode<T>>All nodes indexed by their ID.
children: HashMap<ListId, Vec<ListId>>Children of each node (for ordering). Maps origin -> list of children sorted by ID.
replica_id: StringThe replica ID for this instance.
seq: u64Sequence counter for generating IDs.
pending_delta: Option<RGAListDelta<T>>Pending delta for replication.
Implementations§
Source§impl<T: Clone + PartialEq> RGAList<T>
impl<T: Clone + PartialEq> RGAList<T>
Sourcepub fn replica_id(&self) -> &str
pub fn replica_id(&self) -> &str
Get the replica ID.
Sourcepub fn insert_after(&mut self, origin: &ListId, value: T)
pub fn insert_after(&mut self, origin: &ListId, value: T)
Insert a value after the given origin ID.
Sourcepub fn push_front(&mut self, value: T)
pub fn push_front(&mut self, value: T)
Insert at the beginning.
Sourcepub fn delete_by_id(&mut self, id: &ListId) -> Option<T>
pub fn delete_by_id(&mut self, id: &ListId) -> Option<T>
Delete an element by its ID.
Sourcepub fn move_element(&mut self, from: usize, to: usize) -> bool
pub fn move_element(&mut self, from: usize, to: usize) -> bool
Move an element from one index to another.
Sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut T>
pub fn get_mut(&mut self, index: usize) -> Option<&mut T>
Get a mutable reference to the element at the given index.
Sourcepub fn iter_indexed(&self) -> impl Iterator<Item = (usize, &T)>
pub fn iter_indexed(&self) -> impl Iterator<Item = (usize, &T)>
Iterate over (index, value) pairs.
Sourcefn id_at_index(&self, index: usize) -> Option<ListId>
fn id_at_index(&self, index: usize) -> Option<ListId>
Get the ID at a given visible index.
Sourcepub fn index_of_id(&self, id: &ListId) -> Option<usize>
pub fn index_of_id(&self, id: &ListId) -> Option<usize>
Get the visible index for an ID.
Sourcefn iter_nodes(&self) -> impl Iterator<Item = &ListNode<T>>
fn iter_nodes(&self) -> impl Iterator<Item = &ListNode<T>>
Iterate over all nodes in order (including tombstones).
Sourcefn integrate_node(&mut self, node: ListNode<T>)
fn integrate_node(&mut self, node: ListNode<T>)
Integrate a node into the list.
Sourcepub fn take_delta(&mut self) -> Option<RGAListDelta<T>>
pub fn take_delta(&mut self) -> Option<RGAListDelta<T>>
Take the pending delta.
Sourcepub fn apply_delta(&mut self, delta: &RGAListDelta<T>)
pub fn apply_delta(&mut self, delta: &RGAListDelta<T>)
Apply a delta from another replica.