Struct ywasm::YXmlText [−][src]
pub struct YXmlText(_);
Expand description
A shared data type used for collaborative text editing, that can be used in a context of
YXmlElement
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
YTransaction.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 YXmlElement
, YXmlText
can be marked with extra metadata in form of attributes.
YXmlText
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, YXmlText
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.
Implementations
Returns length of an underlying string stored in this YXmlText
instance,
understood as a number of UTF-8 encoded bytes.
Inserts a given chunk
of text into this YXmlText
instance, starting at a given index
.
Appends a given chunk
of text at the end of YXmlText
instance.
Deletes a specified range of of characters, starting at a given index
.
Both index
and length
are counted in terms of a number of UTF-8 character bytes.
Returns a next XML sibling node of this XMl node.
It can be either YXmlElement
, YXmlText
or undefined
if current node is a last child of
parent XML node.
Returns a previous XML sibling node of this XMl node.
It can be either YXmlElement
, YXmlText
or undefined
if current node is a first child
of parent XML node.
Returns a parent YXmlElement
node or undefined
if current node has no parent assigned.
Returns an underlying string stored in this YXmlText
instance.
Sets a name
and value
as new attribute for this XML node. If an attribute with the same
name
already existed on that node, its value with be overridden with a provided one.
Returns a value of an attribute given its name
. If no attribute with such name existed,
null
will be returned.
Removes an attribute from this XML node, given its name
.
Returns an iterator that enables to traverse over all attributes of this XML node in unspecified order.
Trait Implementations
The type that holds the reference to Self
for the duration of the
invocation of the function that has an &Self
parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous. Read more
Recover a Self::Anchor
from Self::Abi
. Read more