Struct yrs::block::ItemPtr

source ·
pub struct ItemPtr(/* private fields */);
Expand description

A raw Item pointer. As the underlying block doesn’t move it’s in-memory location, ItemPtr can be considered a pinned object.

Methods from Deref<Target = Item>§

source

pub fn encode<E: Encoder>(&self, encoder: &mut E)

source

pub fn id(&self) -> &ID

Returns a unique identifier of a first update contained by a current Item.

source

pub fn contains(&self, id: &ID) -> bool

Checks if provided id fits inside of updates defined within bounds of current Item.

source

pub fn is_deleted(&self) -> bool

Checks if current item is marked as deleted (tombstoned). Yrs uses soft item deletion mechanism, which means that deleted values are not physically erased from memory, but just marked as deleted.

source

pub fn is_countable(&self) -> bool

Checks if item content can be considered countable. Countable elements can be split and joined together.

source

pub fn len(&self) -> u32

Returns a length of a block. For most situation it works like Item::content_len with a difference to a Text/[XmlText] contents - in order to achieve compatibility with Yjs we need to calculate string length in terms of UTF-16 character encoding. However depending on used [Encoding] scheme we may calculate string length/offsets differently.

source

pub fn content_len(&self, kind: OffsetKind) -> u32

source

pub fn last_id(&self) -> ID

Returns an ID of the last element that can be considered a part of this item.

source

pub fn info(&self) -> u8

Trait Implementations§

source§

impl Clone for ItemPtr

source§

fn clone(&self) -> ItemPtr

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ItemPtr

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deref for ItemPtr

§

type Target = Item

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for ItemPtr

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl Display for ItemPtr

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a Box<Item>> for ItemPtr

source§

fn from(block: &'a Box<Item>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a mut Box<Item>> for ItemPtr

source§

fn from(block: &'a mut Box<Item>) -> Self

Converts to this type from the input type.
source§

impl Hash for ItemPtr

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl IntoIterator for ItemPtr

§

type Item = ItemPtr

The type of the elements being iterated over.
§

type IntoIter = BlockIter

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq for ItemPtr

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<ItemPtr> for Any

§

type Error = ItemPtr

The type returned in the event of a conversion error.
source§

fn try_from(item: ItemPtr) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<ItemPtr> for ArrayRef

§

type Error = ItemPtr

The type returned in the event of a conversion error.
source§

fn try_from(value: ItemPtr) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<ItemPtr> for Doc

§

type Error = ItemPtr

The type returned in the event of a conversion error.
source§

fn try_from(item: ItemPtr) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<ItemPtr> for MapRef

§

type Error = ItemPtr

The type returned in the event of a conversion error.
source§

fn try_from(value: ItemPtr) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<ItemPtr> for TextRef

§

type Error = ItemPtr

The type returned in the event of a conversion error.
source§

fn try_from(value: ItemPtr) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<ItemPtr> for Unused

§

type Error = ItemPtr

The type returned in the event of a conversion error.
source§

fn try_from(_: ItemPtr) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<ItemPtr> for XmlElementRef

§

type Error = ItemPtr

The type returned in the event of a conversion error.
source§

fn try_from(value: ItemPtr) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<ItemPtr> for XmlFragmentRef

§

type Error = ItemPtr

The type returned in the event of a conversion error.
source§

fn try_from(value: ItemPtr) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<ItemPtr> for XmlTextRef

§

type Error = ItemPtr

The type returned in the event of a conversion error.
source§

fn try_from(value: ItemPtr) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for ItemPtr

source§

impl Eq for ItemPtr

Auto Trait Implementations§

§

impl Freeze for ItemPtr

§

impl !RefUnwindSafe for ItemPtr

§

impl !Send for ItemPtr

§

impl !Sync for ItemPtr

§

impl Unpin for ItemPtr

§

impl !UnwindSafe for ItemPtr

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.