Struct yrs::Transaction[][src]

pub struct Transaction<'a> {
    pub before_state: StateVector,
    pub after_state: StateVector,
    pub merge_blocks: Vec<ID>,
    pub delete_set: DeleteSet,
    // some fields omitted
}
Expand description

Transaction is one of the core types in Yrs. All operations that need to touch a document’s contents (a.k.a. block store), need to be executed in scope of a transaction.

Fields

before_state: StateVector

State vector of a current transaction at the moment of its creation.

after_state: StateVector

Current state vector of a transaction, which includes all performed updates.

merge_blocks: Vec<ID>

ID’s of the blocks to be merged.

delete_set: DeleteSet

Describes the set of deleted items by ids.

Implementations

Returns state vector describing current state of the updates.

Encodes the difference between remove peer state given its state_vector and the state of a current local peer

Returns a Text data structure stored under a given name. Text structures are used for collaborative text editing: they expose operations to append and remove chunks of text, which are free to execute concurrently by multiple peers over remote boundaries.

If not structure under defined name existed before, it will be created and returned instead.

If a structure under defined name already existed, but its type was different it will be reinterpreted as a text (in such case a sequence component of complex data type will be interpreted as a list of text chunks).

Returns a Map data structure stored under a given name. Maps are used to store key-value pairs associated together. These values can be primitive data (similar but not limited to a JavaScript Object Notation) as well as other shared types (Yrs maps, arrays, text structures etc.), enabling to construct a complex recursive tree structures.

If not structure under defined name existed before, it will be created and returned instead.

If a structure under defined name already existed, but its type was different it will be reinterpreted as a map (in such case a map component of complex data type will be interpreted as native map).

Returns an Array data structure stored under a given name. Array structures are used for storing a sequences of elements in ordered manner, positioning given element accordingly to its index.

If not structure under defined name existed before, it will be created and returned instead.

If a structure under defined name already existed, but its type was different it will be reinterpreted as an array (in such case a sequence component of complex data type will be interpreted as a list of inserted values).

Returns a XmlElement data structure stored under a given name. XML elements represent nodes of XML document. They can contain attributes (key-value pairs, both of string type) as well as other nested XML elements or text values, which are stored in their insertion order.

If not structure under defined name existed before, it will be created and returned instead.

If a structure under defined name already existed, but its type was different it will be reinterpreted as a XML element (in such case a map component of complex data type will be interpreted as map of its attributes, while a sequence component - as a list of its child XML nodes).

Returns a XmlText data structure stored under a given name. Text structures are used for collaborative text editing: they expose operations to append and remove chunks of text, which are free to execute concurrently by multiple peers over remote boundaries.

If not structure under defined name existed before, it will be created and returned instead.

If a structure under defined name already existed, but its type was different it will be reinterpreted as a text (in such case a sequence component of complex data type will be interpreted as a list of text chunks).

Encodes the document state to a binary format.

Document updates are idempotent and commutative. Caveats:

  • It doesn’t matter in which order document updates are applied.
  • As long as all clients receive the same document updates, all clients end up with the same content.
  • Even if an update contains known information, the unknown information is extracted and integrated into the document structure.

Commits current transaction. This step involves cleaning up and optimizing changes performed during lifetime of a transaction. Such changes include squashing delete sets data or squashing blocks that have been appended one after another to preserve memory.

This step is performed automatically when a transaction is about to be dropped (its life scope comes to an end).

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.