Struct yrs::types::array::Array[][src]

pub struct Array(_);
Expand description

A collection used to store data in an indexed sequence structure. This type is internally implemented as a double linked list, which may squash values inserted directly one after another into single list node upon transaction commit.

Reading a root-level type as an YArray means treating its sequence components as a list, where every countable element becomes an individual entity:

  • JSON-like primitives (booleans, numbers, strings, JSON maps, arrays etc.) are counted individually.
  • Text chunks inserted by [Text] data structure: each character becomes an element of an array.
  • Embedded and binary values: they count as a single element even though they correspond of multiple bytes.

Like all Yrs shared data types, YArray is resistant to the problem of interleaving (situation when elements 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 a number of elements stored in current array.

Inserts a value at the given index. Inserting at index 0 is equivalent to prepending current array with given value, while inserting at array length is equivalent to appending that value at the end of it.

Using index value that’s higher than current array length results in panic.

Inserts multiple values at the given index. Inserting at index 0 is equivalent to prepending current array with given values, while inserting at array length is equivalent to appending that value at the end of it.

Using index value that’s higher than current array length results in panic.

Inserts given value at the end of the current array.

Inserts given value at the beginning of the current array.

Removes a single element at provided index.

Removes a range of elements from current array, starting at given index up until a particular number described by len has been deleted. This method panics in case when not all expected elements were removed (due to insufficient number of elements in an array) or index is outside of the bounds of an array.

Retrieves a value stored at a given index. Returns None when provided index was out of the range of a current array.

Returns an iterator, that can be used to lazely traverse over all values stored in a current array.

Converts all contents of current array into a JSON-like representation.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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 resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.