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>
impl<E: ContentTraits, I: TreeMetrics<E>, const IE: usize, const LE: usize> UnsafeCursor<E, I, IE, LE>
Sourcepub fn traverse_forward(&mut self) -> bool
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.
pub fn traverse_backwards(&mut self) -> bool
Sourcepub fn prev_entry_marker(&mut self, marker: Option<&mut I::Update>) -> bool
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.
pub fn prev_entry(&mut self) -> bool
Sourcepub fn next_entry_marker(&mut self, marker: Option<&mut I::Update>) -> bool
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.
pub fn next_entry(&mut self) -> bool
Sourcepub unsafe fn count_pos_raw<Out, F, G, H>(
&self,
offset_to_num: F,
entry_len: G,
entry_len_at: H,
) -> Out
pub unsafe fn count_pos_raw<Out, F, G, H>( &self, offset_to_num: F, entry_len: G, entry_len_at: H, ) -> Out
§Safety
This method assumes (but does not check) that the cursor outlives the container.
Sourcepub unsafe fn count_pos(&self) -> I::Value
pub unsafe fn count_pos(&self) -> I::Value
§Safety
This method assumes (but does not check) that the cursor outlives the container.
Sourcepub fn get_raw_entry(&self) -> &E
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
Sourcepub fn roll_to_next_entry_marker(&mut self, marker: &mut I::Update) -> bool
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.
pub fn next_item(&mut self) -> bool
pub fn move_forward_by_offset( &mut self, amt: usize, marker: Option<&mut I::Update>, )
pub fn move_back_by_offset( &mut self, amt: usize, marker: Option<&mut I::Update>, )
Sourcepub fn compress_node(&mut self)
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.
pub fn check(&self)
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>
impl<E: ContentTraits + Searchable, I: TreeMetrics<E>, const IE: usize, const LE: usize> UnsafeCursor<E, I, IE, LE>
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>
impl<E: ContentTraits + ContentLength, I: FindContent<E>, const IE: usize, const LE: usize> UnsafeCursor<E, I, IE, LE>
pub unsafe fn unsafe_count_content_pos(&self) -> usize
pub fn move_forward_by_content(&mut self, _amt: usize)
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>
impl<E: ContentTraits, I: FindOffset<E>, const IE: usize, const LE: usize> UnsafeCursor<E, I, IE, LE>
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>
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>
fn clone(&self) -> UnsafeCursor<E, I, IE, LE>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more