Struct ditto::counter::Counter [] [src]

pub struct Counter { /* fields omitted */ }

A Counter is an i64 value that can be incremented and decremented via the increment function.

Internally, Counter is a variant of GCounter that allows op-based replication via execute_op and state-based replication via merge. Both replication methods are idempotent and can handle out-of-order delivery.

Counter has a spatial complexity of O(S), where S is the number of sites that have incremented the Counter. It has the following performance characteristics:

Methods

impl Counter
[src]

[src]

Constructs and returns a new Counter with site id 1.

[src]

Returns the counter value.

[src]

Increments the counter by the given amount and returns an op that can be replicated to other sites. If the counter does not have a site id, it caches the op and returns an AwaitingSiteId error.

[src]

Returns the Counter's site id.

[src]

Returns a reference to the Counter state.

[src]

Clones and returns the Counter state.

[src]

Consumes the Counter and returns its state.

[src]

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

[src]

Executes an Op and returns the equivalent increment. If the op has already been executed or superceded, nothing is done.

[src]

Validates that an op comes from a specific site id, then executes the op.

[src]

Merges remote state into the Counter.

[src]

Assigns a site id and returns a cached op if it exists.

Trait Implementations

impl Debug for Counter
[src]

[src]

Formats the value using the given formatter. Read more

impl Clone for Counter
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq for Counter
[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 Send for Counter

impl Sync for Counter