Struct xarray::CursorMut

source ·
pub struct CursorMut<'a, I, M>
where I: ItemEntry, M: Into<XMark>,
{ /* private fields */ }
Expand description

A CursorMut can traverse in the XArray by setting or increasing the target index and can perform read-write operations to the target item represented by the target index.

CursorMuts act like exclusive references, so multiple cursors are not allowed to operate on a single XArray at the same time.

The typical way to obtain a CursorMut instance is to call XArray::cursor_mut.

Features for COW (Copy-On-Write). Due to COW, multiple XArrays can share the same piece of data. As a result, CursorMut does not always have exclusive access to the items stored in the XArray. However, just before performing the modification, CursorMut will create exclusive copies by cloning shared items, which guarantees the isolation of data stored in different XArrays.

Implementations§

source§

impl<'a, I: ItemEntry, M: Into<XMark>> CursorMut<'a, I, M>

source

pub fn reset_to(&mut self, index: u64)

Resets the target index to index.

Once set, the cursor will be positioned on the corresponding leaf node, if the leaf node exists.

source

pub fn index(&self) -> u64

Returns the target index of the cursor.

source

pub fn next(&mut self)

Increases the target index of the cursor by one.

Once increased, the cursor will be positioned on the corresponding leaf node, if the leaf node exists.

source

pub fn load(&mut self) -> Option<I::Ref<'_>>

Loads the item at the target index.

If the target item exists, this method will return a ItemEntry::Ref that acts exactly like a &'_ I wrapped in Some(_). Otherwises, it will return None.

source

pub fn is_marked(&mut self, mark: M) -> bool

Checks whether the target item is marked with the input mark.

If the target item does not exist, this method will also return false.

source

pub fn store(&mut self, item: I) -> Option<I>

Stores a new item at the target index, and returns the old item if it previously exists.

source

pub fn remove(&mut self) -> Option<I>

Removes the item at the target index, and returns the removed item if it previously exists.

source

pub fn set_mark(&mut self, mark: M) -> Result<(), ()>

Sets the input mark for the item at the target index if the target item exists, otherwise returns an error.

source

pub fn unset_mark(&mut self, mark: M) -> Result<(), ()>

Unsets the input mark for the item at the target index if the target item exists, otherwise returns an error.

Trait Implementations§

source§

impl<'a, I: ItemEntry, M: Into<XMark>> Drop for CursorMut<'a, I, M>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, I, M> Freeze for CursorMut<'a, I, M>

§

impl<'a, I, M> RefUnwindSafe for CursorMut<'a, I, M>
where M: RefUnwindSafe, I: RefUnwindSafe,

§

impl<'a, I, M> Send for CursorMut<'a, I, M>
where M: Send, I: Send + Sync,

§

impl<'a, I, M> Sync for CursorMut<'a, I, M>
where M: Sync, I: Sync + Send,

§

impl<'a, I, M> Unpin for CursorMut<'a, I, M>

§

impl<'a, I, M> !UnwindSafe for CursorMut<'a, I, M>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.