Struct Item
pub struct Item { /* private fields */ }Expand description
Block defines a range of consecutive updates performed by the same peer. While individual updates are always uniquely defined by their corresponding IDs, they may contain a lot of additional metadata. Block representation here is crucial, since it optimizes memory usage, available when multiple updates have been performed one after another (eg. when user is writing a sentence, individual key strokes are independent updates but they can be compresses into a single block containing an entire sentence for as long as another piece of data is not being inserted in the middle it).
Implementations§
§impl Item
impl Item
pub fn contains(&self, id: &ID) -> bool
pub fn contains(&self, id: &ID) -> bool
Checks if provided id fits inside of updates defined within bounds of current Item.
pub fn is_deleted(&self) -> bool
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.
pub fn is_countable(&self) -> bool
pub fn is_countable(&self) -> bool
Checks if item content can be considered countable. Countable elements can be split and joined together.
pub fn len(&self) -> u32
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.
pub fn content_len(&self, kind: OffsetKind) -> u32
pub fn last_id(&self) -> ID
pub fn last_id(&self) -> ID
Returns an ID of the last element that can be considered a part of this item.
pub fn info(&self) -> u8
Trait Implementations§
impl StructuralPartialEq for Item
Auto Trait Implementations§
impl Freeze for Item
impl !RefUnwindSafe for Item
impl !Send for Item
impl !Sync for Item
impl Unpin for Item
impl !UnwindSafe for Item
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
§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.