Struct ditto::list::List [] [src]

pub struct List<T: 'static> { /* fields omitted */ }

A List is a Vec-like ordered sequence of elements. List elements must implement the Clone, Serialize, and Deserialize traits.

Internally, List is based on LSEQ. It allows op-based replication via execute_op and state-based replication via merge. State-based replication allows out-of-order delivery but op-based replication does not.

List's performance characteristics are similar to Vec:

  • push: O(1)
  • pop: O(1)
  • insert: O(N)
  • remove: O(N)
  • get: O(1)
  • execute_op: O(N)
  • merge: O(N1 + N2 + S1 + S2), where N1 and N2 are the number of values in each list being merged, and S1 and S2 are the number of sites that have edited each list being merged.

Methods

impl<T: Clone> List<T>
[src]

[src]

Constructs and returns a new List with site id 1.

[src]

Returns the number of elements in the list.

[src]

Returns true if the List has a length of 0. Returns false otherwise

[src]

Returns a reference to the element at position idx. Returns None if idx is out-of-bounds.

[src]

Pushes a value onto the end of the list. If the list does not have a site id, it caches the resulting op and returns an AwaitingSiteId error.

[src]

Removes the value at the end of the list, if the list is nonempty. If the list is empty, it returns None. If the pop succeeds but the list does not have a site id, it caches the resulting op and returns an AwaitingSiteId error.

[src]

Inserts a value at position idx in the list, shifting all elements after it to the right. Panics if the idx is out of bounds. If the insert succeeds but the list does not have a site id, it caches the resulting op and returns an AwaitingSiteId error.

[src]

Removes the element at position idx from the list, shifting all elements after it to the left. Panics if the idx is out-of-bounds. If the remove succeeds but the list does not have a site id, it caches the resulting op and returns an AwaitingSiteId error.

[src]

Returns the site id.

[src]

Returns a borrowed CRDT state.

[src]

Returns an owned CRDT state of cloned values.

[src]

Consumes the CRDT and returns its state

[src]

Constructs a new CRDT from a state and optional site id. If the site id is present, it must be nonzero.

[src]

Returns the CRDT value's equivalent local value.

[src]

Executes an op and returns the equivalent local op. This function assumes that the op always inserts values from the correct site. For untrusted ops, used validate_and_execute_op.

[src]

Validates that an op only inserts elements from a given site id, then executes the op and returns the equivalent local op.

[src]

Merges a remote CRDT state into the CRDT. The remote CRDT state must have a site id.

[src]

Assigns a site id to the CRDT and returns any cached ops. If the CRDT already has a site id, it returns an error.

Trait Implementations

impl<T: Debug + 'static> Debug for List<T>
[src]

[src]

Formats the value using the given formatter. Read more

impl<T: Clone + 'static> Clone for List<T>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: PartialEq + 'static> PartialEq for List<T>
[src]

[src]

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

[src]

This method tests for !=.

impl<T: Clone> From<Vec<T>> for List<T>
[src]

[src]

Performs the conversion.

Auto Trait Implementations

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

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