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

Create an empty List

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().

Get the length of the List.

Check if the List is empty.

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 the elements represented by the List.

Get each elements identifier and value from the List.

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

Finds an element by its Identifier.

Get first element of the sequence represented by the List.

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

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

Get last element of the sequence represented by the List.

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

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

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

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.