Struct UnsafeCursor

Source
pub struct UnsafeCursor<E: ContentTraits, I: TreeMetrics<E>, const IE: usize = DEFAULT_IE, const LE: usize = DEFAULT_LE> {
    pub offset: usize,
    /* private fields */
}
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§

Source§

impl<E: ContentTraits, I: TreeMetrics<E>, const IE: usize, const LE: usize> UnsafeCursor<E, I, IE, LE>

Source

pub fn traverse_forward(&mut self) -> bool

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.

Source

pub fn traverse_backwards(&mut self) -> bool

Source

pub fn prev_entry_marker(&mut self, marker: Option<&mut I::Update>) -> 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.

Source

pub fn prev_entry(&mut self) -> bool

Source

pub fn next_entry_marker(&mut self, marker: Option<&mut I::Update>) -> 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.

Source

pub fn next_entry(&mut self) -> bool

Source

pub unsafe fn count_pos_raw<Out, F, G, H>( &self, offset_to_num: F, entry_len: G, entry_len_at: H, ) -> Out
where Out: AddAssign + Default, F: Fn(I::Value) -> Out, G: Fn(&E) -> Out, H: Fn(&E, usize) -> Out,

§Safety

This method assumes (but does not check) that the cursor outlives the container.

Source

pub unsafe fn count_pos(&self) -> I::Value

§Safety

This method assumes (but does not check) that the cursor outlives the container.

Source

pub fn get_raw_entry(&self) -> &E

Note this ignores the cursor’s offset.

Source

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

Source

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

Source

pub fn roll_to_next_entry(&mut self) -> bool

Source

pub fn roll_to_next_entry_marker(&mut self, marker: &mut I::Update) -> bool

Also a terrible name. Roll to the next entry. If we move to a new node, flush the marker.

Source

pub fn next_item(&mut self) -> bool

Source

pub fn move_forward_by_offset( &mut self, amt: usize, marker: Option<&mut I::Update>, )

Source

pub fn move_back_by_offset( &mut self, amt: usize, marker: Option<&mut I::Update>, )

Source

pub fn compress_node(&mut self)

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

Source

pub fn check(&self)

Source

pub unsafe fn unsafe_cmp(&self, other: &Self) -> Ordering

Source§

impl<E: ContentTraits + Searchable, I: TreeMetrics<E>, const IE: usize, const LE: usize> UnsafeCursor<E, I, IE, LE>

Source

pub unsafe fn unsafe_get_item(&self) -> Option<E::Item>

Source§

impl<E: ContentTraits + ContentLength, I: FindContent<E>, const IE: usize, const LE: usize> UnsafeCursor<E, I, IE, LE>

Source

pub unsafe fn unsafe_count_content_pos(&self) -> usize

Source

pub fn move_forward_by_content(&mut self, _amt: usize)

Source

pub fn move_back_by_content(&mut self, _amt: usize)

Source§

impl<E: ContentTraits, I: FindOffset<E>, const IE: usize, const LE: usize> UnsafeCursor<E, I, IE, LE>

Source

pub unsafe fn unsafe_count_offset_pos(&self) -> usize

Trait Implementations§

Source§

impl<E: Clone + ContentTraits, I: Clone + TreeMetrics<E>, const IE: usize, const LE: usize> Clone for UnsafeCursor<E, I, IE, LE>

Source§

fn clone(&self) -> UnsafeCursor<E, I, IE, LE>

Returns a duplicate 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<E: Debug + ContentTraits, I: Debug + TreeMetrics<E>, const IE: usize, const LE: usize> Debug for UnsafeCursor<E, I, IE, LE>

Source§

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

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

impl<R, E: ContentTraits, I: TreeMetrics<E>, const IE: usize, const LE: usize> From<SafeCursor<R, E, I, IE, LE>> for UnsafeCursor<E, I, IE, LE>

Source§

fn from(c: SafeCursor<R, E, I, IE, LE>) -> Self

Converts to this type from the input type.
Source§

impl<E: ContentTraits, I: TreeMetrics<E>, const IE: usize, const LE: usize> PartialEq for UnsafeCursor<E, I, IE, LE>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<E: ContentTraits, I: TreeMetrics<E>, const IE: usize, const LE: usize> Eq for UnsafeCursor<E, I, IE, LE>

Auto Trait Implementations§

§

impl<E, I, const IE: usize, const LE: usize> Freeze for UnsafeCursor<E, I, IE, LE>

§

impl<E, I, const IE: usize, const LE: usize> RefUnwindSafe for UnsafeCursor<E, I, IE, LE>

§

impl<E, I, const IE: usize = DEFAULT_IE, const LE: usize = DEFAULT_LE> !Send for UnsafeCursor<E, I, IE, LE>

§

impl<E, I, const IE: usize = DEFAULT_IE, const LE: usize = DEFAULT_LE> !Sync for UnsafeCursor<E, I, IE, LE>

§

impl<E, I, const IE: usize, const LE: usize> Unpin for UnsafeCursor<E, I, IE, LE>

§

impl<E, I, const IE: usize, const LE: usize> UnwindSafe for UnsafeCursor<E, I, IE, LE>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.