Struct yrs::types::xml::XmlTextRef

source ·
#[repr(transparent)]
pub struct XmlTextRef(_);
Expand description

A shared data type used for collaborative text editing, that can be used in a context of [XmlElement] nodee. It enables multiple users to add and remove chunks of text in efficient manner. This type is internally represented as a mutable double-linked list of text chunks

  • an optimization occurs during [Transaction::commit], which allows to squash multiple consecutively inserted characters together as a single chunk of text even between transaction boundaries in order to preserve more efficient memory model.

Just like [XmlElement], [XmlText] can be marked with extra metadata in form of attributes.

[XmlText] structure internally uses UTF-8 encoding and its length is described in a number of bytes rather than individual characters (a single UTF-8 code point can consist of many bytes).

Like all Yrs shared data types, [XmlText] is resistant to the problem of interleaving (situation when characters inserted one after another may interleave with other peers concurrent inserts after merging all updates together). In case of Yrs conflict resolution is solved by using unique document id to determine correct and consistent ordering.

Trait Implementations§

Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Displays the content of a current collection in string format.
Subscribes a given callback to be triggered whenever current y-type is changed. A callback is triggered whenever a transaction gets committed. This function does not trigger if changes have been observed by nested shared collections. Read more
Unsubscribes a previously subscribed event callback identified by given subscription_id.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Returns a number of characters visible in a current text data structure.
Inserts a chunk of text at a given index. If index is 0, this chunk will be inserted at the beginning of a current text. If index is equal to current data structure length, this chunk will be appended at the end of it. Read more
Inserts a chunk of text at a given index. If index is 0, this chunk will be inserted at the beginning of a current text. If index is equal to current data structure length, this chunk will be appended at the end of it. Collection of supplied attributes will be used to wrap provided text chunk range with a formatting blocks. Read more
Inserts an embed content at a given index. Read more
Inserts an embed content of text at a given index. If index is 0, this content will be inserted at the beginning of a current text. If index is equal to current data structure length, this chunk will be appended at the end of it. Collection of supplied attributes will be used to wrap provided text content range with a formatting blocks. Read more
Appends a given chunk of text at the end of a current text structure.
Removes up to a len characters from a current text structure, starting at given index. This method panics in case when not all expected characters were removed (due to insufficient number of characters to remove) or index is outside of the bounds of text. Read more
Wraps an existing piece of text within a range described by index-len parameters with formatting blocks containing provided attributes metadata. Read more
Returns the Delta representation of this YText type.
The type returned in the event of a conversion error.
Performs the conversion.
Removes an attribute recognized by an attr_name from a current XML element.
Inserts an attribute entry into current XML element.
Returns a value of an attribute given its attr_name. Returns None if no such attribute can be found inside of a current XML element. Read more
Returns an unordered iterator over all attributes (key-value pairs), that can be found inside of a current XML element. 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
Subscribe a callback f for all events emitted by this and nested collaborative types. Callback is accepting transaction which triggered that event and event itself, wrapped within an Event structure. Read more
Unobserves callback identified by subscription_id (which can be obtained by consuming Subscription using into cast). Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.