Enum yrs::block::ItemContent[][src]

pub enum ItemContent {
    Any(Vec<Any>),
    Binary(Vec<u8>),
    Deleted(u32),
    Doc(StringAny),
    JSON(Vec<String>),
    Embed(String),
    Format(StringString),
    String(String),
    Type(BranchRef),
}
Expand description

An enum describing the type of a user content stored as part of one or more (if items were squashed) insert operations.

Variants

Any(Vec<Any>)

Any JSON-like primitive type range.

Tuple Fields of Any

0: Vec<Any>
Binary(Vec<u8>)

A binary data eg. images.

Tuple Fields of Binary

0: Vec<u8>
Deleted(u32)

A marker for delete item data, which describes a number of deleted elements. Deleted elements also don’t contribute to an overall length of containing collection type.

Tuple Fields of Deleted

0: u32
Doc(StringAny)

Tuple Fields of Doc

0: String1: Any
JSON(Vec<String>)

Tuple Fields of JSON

0: Vec<String>
Embed(String)

Tuple Fields of Embed

0: String
Format(StringString)

Formatting attribute entry. Format attributes are not considered countable and don’t contribute to an overall length of a collection they are applied to.

Tuple Fields of Format

0: String1: String
String(String)

A chunk of text, usually applied by collaborative text insertion.

Tuple Fields of String

0: String
Type(BranchRef)

A reference of a branch node. Branch nodes define a complex collection types, such as arrays, maps or XML elements.

Tuple Fields of Type

0: BranchRef

Implementations

Returns a reference number used to determine a content type. It’s used during encoding/decoding of a containing block.

Checks if item content can be considered countable. Countable elements contribute to a length of the block they are contained by. Most of the item content variants are countable with exception for ItemContent::Deleted (which length describes number of removed elements) and ItemContent::Format (which is used for storing text formatting tags).

Returns a number of separate elements contained within current item content struct.

Separate elements can be split in order to put another block in between them. Definition of separation depends on a item content kin, eg. ItemContent::String, ItemContent::Any, ItemContent::JSON and ItemContent::Deleted can have variable length as they may be split by other insert operations. Other variants (eg. ItemContent::Binary) are considered as a single element and therefore their length is always 1 and are not considered as subject of splitting.

In cases of counting number of visible elements, len method should be used together with ItemContent::is_countable.

Returns a formatted content of an item. For complex types (represented by BranchRef nodes) it will return a target type of a branch node (eg. Yrs Array, Map or XmlElement). For other types it will returns a vector of elements stored within current block. Since block may describe a chunk of values within it, it always returns a vector of values.

Similar to [get_content], but it only returns the latest result and doesn’t materialize others for performance reasons.

Tries to squash two item content structures together.

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

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

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

Converts the given value to a String. 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.