Struct ditto::json::Json [] [src]

pub struct Json { /* fields omitted */ }

Json is a CRDT that stores a JSON value. It can handle any kind of JSON value (object, array, string, number, bool, and null) and allows arbitrarily-nested values. A nested Json value is indexed by a JSON pointer.

Internally, Json is built on Ditto's Map, List, and Text CRDTs. 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.

The root value of a Json CRDT (typically an object or array) cannot be replaced; for example, a Json CRDT whose root is an array will always have an array as its root. This constraint means that any Json CRDT with a numeric, boolean, or null root is immutable.

Methods

impl Json
[src]

[src]

Constructs and returns a new Json CRDT with site 1 from any value that satisfies the IntoJson trait.

[src]

Constructs and returns a new Json CRDT with site 1 from an unparsed JSON string.

[src]

Returns the number of elements in a container at the given pointer in the Json CRDT. If there is no container at the given pointer, returns None.

[src]

Inserts a value into the Json CRDT at the given json pointer. The enclosing value may be an object or an array and the inserted value must satisfy the IntoJson trait.

If the CRDT does not have a site id allocated, it caches the op and returns an AwaitingSite error.

[src]

Inserts a value into the Json CRDT at the given json pointer. The enclosing value may be an object or an array and the value being inserted is stringified JSON.

If the CRDT does not have a site id allocated, it caches the op and returns an AwaitingSite error.

[src]

Removes a value at the given JSON pointer from the Json CRDT. If the enclosing value is an object, it deletes the key-value pair. If the enclosing value is an array, it deletes the value at the array index.

If the CRDT does not have a site id allocated, it caches the op and returns an AwaitingSite error.

[src]

Replaces a text range in a text value in the Json CRDT. If the CRDT does not have a site id 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 Debug for Json
[src]

[src]

Formats the value using the given formatter. Read more

impl Clone for Json
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

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

impl Sync for Json