Struct crdts::list::List [−][src]
pub struct List<T, A: Ord> { /* fields omitted */ }
Expand description
As described in the module documentation:
A List is a CRDT for storing sequences of data (Strings, ordered lists). It provides an efficient view of the stored sequence, with fast index, insertion and deletion operations.
Implementations
Generate an op to insert the given element at the given index.
If ix
is greater than the length of the List then it is appended to the end.
Create an op to insert an element at the end of the sequence.
Create an op to delete the element at the given index.
Returns None if ix
is out of bounds, i.e. ix > self.len()
.
Read the List into a container of your choice
use crdts::{List, CmRDT}; let mut list = List::new(); list.apply(list.append('a', 'A')); list.apply(list.append('b', 'A')); list.apply(list.append('c', 'A')); assert_eq!(list.read::<String>(), "abc");
Read the List into a container of your choice, consuming it.
use crdts::{List, CmRDT}; let mut list = List::new(); list.apply(list.append(1, 'A')); list.apply(list.append(2, 'A')); list.apply(list.append(3, 'A')); assert_eq!(list.read_into::<Vec<_>>(), vec![1, 2, 3]);
Get each elements identifier and value from the List.
Get an element at a position in the sequence represented by the List.
Get the first Entry of the sequence represented by the List.
Get the last Entry of the sequence represented by the List.
Trait Implementations
Apply an operation to an List instance.
If the operation is an insert and the identifier is already present in the List instance the result is a no-op
If the operation is a delete and the identifier is not present in the List instance the result is a no-op
Op defines a mutation to the CRDT. As long as Op’s from one actor are replayed in exactly the same order they were generated by that actor, the CRDT will converge. In other words, we must have a total ordering on each actors operations, while requiring only a partial order over all ops. E.g. Read more
type Validation = DotRange<A>
type Validation = DotRange<A>
The validation error returned by validate_op
.
Some CRDT’s have stricter requirements on how they must be used. To avoid violating these requirements, CRDT’s provide an interface to optionally validate op’s before they are applied. Read more
impl<'de, T, A: Ord> Deserialize<'de> for List<T, A> where
T: Deserialize<'de>,
A: Deserialize<'de>,
impl<'de, T, A: Ord> Deserialize<'de> for List<T, A> where
T: Deserialize<'de>,
A: Deserialize<'de>,
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
Auto Trait Implementations
impl<T, A> RefUnwindSafe for List<T, A> where
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, A> UnwindSafe for List<T, A> where
A: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V