Struct ditto::text::Text [] [src]

pub struct Text { /* fields omitted */ }

Text is a String-like UTF-encoded growable string. It contains a number of optimizations that improve replacement and op execution performance on large strings.

Internally, Text 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.

Text has the following performance characteristics:

  • replace: O(log N)
  • execute_op: O(log N)
  • merge: O(N1 + N2 + S1 + S2), where N1 and N2 are the number of values in each Text being merged, and S1 and S2 are the number of sites that have edited each Text being merged.

Methods

impl Text
[src]

[src]

Constructs and returns a new Text CRDT with site id 1.

[src]

Constructs and returns a new Text CRDT from a string. The Text has site id 1.

[src]

Returns the number of unicode characters in the text.

[src]

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

[src]

Replaces the text in the range [idx..<idx+len] with new text. Panics if the start or stop idx is larger than the Text's length, or if it does not lie on a char boundary. If the Text does not have a site id, it caches the 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 Debug for Text
[src]

[src]

Formats the value using the given formatter. Read more

impl Clone for Text
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq for Text
[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<'a> From<&'a str> for Text
[src]

[src]

Performs the conversion.

Auto Trait Implementations

impl Send for Text

impl Sync for Text