Struct ywasm::YText[][src]

pub struct YText(_);
Expand description

A shared data type used for collaborative text editing. 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.

YText 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, YText 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

Creates a new preliminary instance of a YText shared data type, with its state initialized to provided parameter.

Preliminary instances can be nested into other shared data types such as YArray and YMap. Once a preliminary instance has been inserted this way, it becomes integrated into ywasm document store and cannot be nested again: attempt to do so will result in an exception.

Returns true if this is a preliminary instance of YText.

Preliminary instances can be nested into other shared data types such as YArray and YMap. Once a preliminary instance has been inserted this way, it becomes integrated into ywasm document store and cannot be nested again: attempt to do so will result in an exception.

Returns length of an underlying string stored in this YText instance, understood as a number of UTF-8 encoded bytes.

Returns an underlying shared string stored in this data type.

Returns an underlying shared string stored in this data type.

Inserts a given chunk of text into this YText instance, starting at a given index.

Appends a given chunk of text at the end of current YText 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.

Trait Implementations

Performs the conversion.

Performs the conversion.

The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more

Recover a Self from Self::Abi. Read more

The wasm ABI type that this converts into when crossing the ABI boundary. Read more

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary. Read more

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi. Read more

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more

The wasm ABI type references to Self are recovered from.

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

Same as RefFromWasmAbi::Abi

Same as RefFromWasmAbi::Anchor

Same as RefFromWasmAbi::ref_from_abi

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.

Same as IntoWasmAbi::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err. 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.