Struct content_tree::UnsafeCursor[][src]

pub struct UnsafeCursor<E: ContentTraits, I: TreeIndex<E>, const IE: usize, const LE: usize> {
    pub offset: usize,
    // some fields omitted
}
Expand description

A cursor into some location in a range tree.

Note the state of a cursor is weird in two situations:

  • When a cursor points to a location in between two entries, the cursor could either point to the end of the first entry or the start of the subsequent entry.
  • When a tree is empty, the cursor points past the end of the tree.

Safety: This is unsafe because there’s no associated lifetime on a cursor (its ’static).

The caller must ensure any reads and mutations through an UnsafeCursor are valid WRT the mutability and lifetime of the implicitly referenced content tree. Use Cursor and MutCursor.

Fields

offset: usize

Implementations

Internal method for prev_entry and next_entry when we need to move laterally. This moves the cursor to the next / prev node in the tree, with no regard for the current position.

Returns true if the move was successful, or false if we’re at the first / last item in the tree.

pub fn prev_entry_marker(&mut self, marker: Option<&mut I::IndexUpdate>) -> bool

Move back to the previous entry. Returns true if it exists, otherwise returns false if we’re at the start of the doc already.

pub fn prev_entry(&mut self) -> bool

pub fn next_entry_marker(&mut self, marker: Option<&mut I::IndexUpdate>) -> bool

Go to the next entry marker and update the (optional) flush marker. Returns true if successful, or false if we’ve reached the end of the document.

pub fn next_entry(&mut self) -> bool

pub fn get_raw_entry(&self) -> E

Note this ignores the cursor’s offset.

pub fn try_get_raw_entry(&self) -> Option<E>

pub fn get_raw_entry_mut(&mut self) -> &mut E

pub fn roll_to_next_entry(&mut self) -> bool

This is a terrible name. This method modifies a cursor at the end of an entry to be a cursor to the start of the next entry - potentially in the following leaf.

Returns false if the resulting cursor location points past the end of the tree.

This helper method attempts to minimize the size of the leaf around the cursor using append() methods, when possible.

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

NOTE: This comparator will panic when cursors from different range trees are compared.

Also beware: A cursor pointing to the end of an entry will be considered less than a cursor pointing to the subsequent entry.

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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

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.