Enum ItemContent
pub enum ItemContent {
Any(Vec<Any>),
Binary(Vec<u8>),
Deleted(u32),
Doc(Option<Doc>, Doc),
JSON(Vec<String>),
Embed(Any),
Format(Arc<str>, Box<Any>),
String(SplittableString),
Type(Box<Branch>),
Move(Box<Move>),
}Expand description
An enum describing the type of a user data content stored as part of one or more (if items were squashed) insert operations.
Variants§
Any(Vec<Any>)
Collection of consecutively inserted JSON-like primitive values.
Binary(Vec<u8>)
A BLOB data eg. images. Binaries are treated as a single objects (they are not subjects to splits).
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.
Doc(Option<Doc>, Doc)
Sub-document container. Contains weak reference to a parent document and a child document.
JSON(Vec<String>)
Obsolete: collection of consecutively inserted stringified JSON values.
Embed(Any)
A single embedded JSON-like primitive value.
Format(Arc<str>, Box<Any>)
Formatting attribute entry. Format attributes are not considered countable and don’t contribute to an overall length of a collection they are applied to.
String(SplittableString)
A chunk of text, usually applied by collaborative text insertion.
Type(Box<Branch>)
A reference of a branch node. Branch nodes define a complex collection types, such as arrays, maps or XML elements.
Move(Box<Move>)
Marker for destination location of move operation. Move is used to change position of previously inserted element in a sequence with respect to other operations that may happen concurrently on other peers.
Implementations§
§impl ItemContent
impl ItemContent
pub fn get_ref_number(&self) -> u8
pub fn get_ref_number(&self) -> u8
Returns a reference number used to determine a content type. It’s used during encoding/decoding of a containing block.
pub fn is_countable(&self) -> bool
pub fn is_countable(&self) -> bool
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).
pub fn len(&self, kind: OffsetKind) -> u32
pub fn len(&self, kind: OffsetKind) -> u32
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.
pub fn read(&self, offset: usize, buf: &mut [Out]) -> usize
pub fn read(&self, offset: usize, buf: &mut [Out]) -> usize
Reads a contents of current ItemContent into a given buf, starting from provided
offset. Returns a number of elements read this way (it cannot be longer than buf’s len.
pub fn get_content(&self) -> Vec<Out>
pub fn get_content(&self) -> Vec<Out>
Reads all contents stored in this item and returns them. Use ItemContent::read if you need to read only slice of elements from the corresponding item.
pub fn encode_slice<E>(&self, encoder: &mut E, start: u32, end: u32)where
E: Encoder,
pub fn encode_slice<E>(&self, encoder: &mut E, start: u32, end: u32)where
E: Encoder,
Encodes a slice of a current ItemContent within an index bounds of (start..=end) - both sides inclusive.
pub fn encode<E>(&self, encoder: &mut E)where
E: Encoder,
pub fn decode<D>(decoder: &mut D, ref_num: u8) -> Result<ItemContent, Error>where
D: Decoder,
pub fn try_squash(&mut self, other: &ItemContent) -> bool
pub fn try_squash(&mut self, other: &ItemContent) -> bool
Tries to squash two item content structures together.
Returns true if this method had any effect on current ItemContent (modified it).
Otherwise returns false.
Trait Implementations§
§impl Clone for ItemContent
impl Clone for ItemContent
§fn clone(&self) -> ItemContent
fn clone(&self) -> ItemContent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for ItemContent
impl Debug for ItemContent
§impl Display for ItemContent
impl Display for ItemContent
§impl PartialEq for ItemContent
impl PartialEq for ItemContent
impl StructuralPartialEq for ItemContent
Auto Trait Implementations§
impl Freeze for ItemContent
impl !RefUnwindSafe for ItemContent
impl !Send for ItemContent
impl !Sync for ItemContent
impl Unpin for ItemContent
impl !UnwindSafe for ItemContent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.