Struct ditto::set::Set [] [src]

pub struct Set<T: SetElement> { /* fields omitted */ }

A Set is a HashSet-like collection of distinct elements. As with HashSet, Set requires that the elements implement the Eq and Hash traits. To allow for CRDT replication, they must also implement the Clone, Serialize, and Deserialize traits.

Internally, Set is a variant of OR-Set. 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.

Set has a spatial complexity of O(N + S), where N is the number of values concurrently held in the Set and S is the number of sites that have inserted values into the Set. It has the following performance characteristics:

  • insert: O(1)
  • remove: O(1)
  • contains: O(1)
  • execute_op: O(1)
  • merge: O(N1 + N2 + S1 + S2), where N1 and N2 are the number of values in the sets being merged, and S1 and S2 are the number of sites that have edited sets being merged.

Methods

impl<T: SetElement> Set<T>
[src]

[src]

Constructs and returns a new set CRDT. The set has site 1 and counter 0.

[src]

Returns true iff the set contains the value.

[src]

Inserts a value into the set and returns a remote op that can be sent to remote sites for replication. If the set does not have a site allocated, it caches the op and returns an AwaitingSite error.

[src]

Removes a value from the set and returns a remote op that can be sent to remote sites for replication. If the set does not have a site allocated, it caches the op and returns an AwaitingSite 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 + SetElement> Debug for Set<T>
[src]

[src]

Formats the value using the given formatter. Read more

impl<T: Clone + SetElement> Clone for Set<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 + SetElement> PartialEq for Set<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 !=.

Auto Trait Implementations

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

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