Struct crdts::list::List[][src]

pub struct List<T, A: Ord> { /* fields omitted */ }

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

impl<T, A: Ord + Clone> List<T, A>[src]

pub fn new() -> Self[src]

Create an empty List

pub fn insert_index(&self, ix: usize, val: T, actor: A) -> Op<T, A>[src]

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.

pub fn append(&self, c: T, actor: A) -> Op<T, A>[src]

Create an op to insert an element at the end of the sequence.

pub fn delete_index(&self, ix: usize, actor: A) -> Option<Op<T, A>>[src]

Create an op to delete the element at the given index.

Returns None if ix is out of bounds, i.e. ix > self.len().

pub fn len(&self) -> usize[src]

Get the length of the List.

pub fn is_empty(&self) -> bool[src]

Check if the List is empty.

pub fn read<'a, C: FromIterator<&'a T>>(&'a self) -> C[src]

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");

pub fn read_into<C: FromIterator<T>>(self) -> C[src]

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]);

pub fn iter(&self) -> impl Iterator<Item = &T>[src]

Get the elements represented by the List.

pub fn iter_entries(&self) -> impl Iterator<Item = (&Identifier<OrdDot<A>>, &T)>[src]

Get each elements identifier and value from the List.

pub fn position(&self, ix: usize) -> Option<&T>[src]

Get an element at a position in the sequence represented by the List.

pub fn get(&self, id: &Identifier<OrdDot<A>>) -> Option<&T>[src]

Finds an element by its Identifier.

pub fn first(&self) -> Option<&T>[src]

Get first element of the sequence represented by the List.

pub fn first_entry(&self) -> Option<(&Identifier<OrdDot<A>>, &T)>[src]

Get the first Entry of the sequence represented by the List.

pub fn last(&self) -> Option<&T>[src]

Get last element of the sequence represented by the List.

pub fn last_entry(&self) -> Option<(&Identifier<OrdDot<A>>, &T)>[src]

Get the last Entry of the sequence represented by the List.

Trait Implementations

impl<T: Clone, A: Clone + Ord> Clone for List<T, A>[src]

impl<T, A: Ord + Clone + Debug> CmRDT for List<T, A>[src]

type Op = Op<T, A>

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>

The validation error returned by validate_op.

fn apply(&mut self, op: Self::Op)[src]

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

impl<T: Debug, A: Debug + Ord> Debug for List<T, A>[src]

impl<T, A: Ord> Default for List<T, A>[src]

impl<'de, T, A: Ord> Deserialize<'de> for List<T, A> where
    T: Deserialize<'de>,
    A: Deserialize<'de>, 
[src]

impl<T: Eq, A: Eq + Ord> Eq for List<T, A>[src]

impl<T: Hash, A: Hash + Ord> Hash for List<T, A>[src]

impl<T: PartialEq, A: PartialEq + Ord> PartialEq<List<T, A>> for List<T, A>[src]

impl<T, A: Ord> Serialize for List<T, A> where
    T: Serialize,
    A: Serialize
[src]

impl<T, A: Ord> StructuralEq for List<T, A>[src]

impl<T, A: Ord> StructuralPartialEq for List<T, A>[src]

Auto Trait Implementations

impl<T, A> RefUnwindSafe for List<T, A> where
    A: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, A> Send for List<T, A> where
    A: Send,
    T: Send

impl<T, A> Sync for List<T, A> where
    A: Sync,
    T: Sync

impl<T, A> Unpin for List<T, A>

impl<T, A> UnwindSafe for List<T, A> where
    A: RefUnwindSafe,
    T: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,