Skip to main content

ReadSession

Struct ReadSession 

Source
pub struct ReadSession<'manager, 'tree, S: Store> { /* private fields */ }
Expand description

A reusable root-bound read context for one immutable tree.

The session retains the decoded root and a session-local recent leaf. It is intended to be reused by one worker; methods that update traversal state require &mut self.

Implementations§

Source§

impl<'manager, 'tree, S: Store> ReadSession<'manager, 'tree, S>

Source

pub fn tree(&self) -> &Tree

The immutable tree bound to this session.

Source

pub fn len(&self) -> Result<u64, Error>

Return the number of logical entries using the retained root.

Source

pub fn is_empty(&self) -> Result<bool, Error>

Return whether the bound tree contains no entries.

Source

pub fn rank(&mut self, key: &[u8]) -> Result<u64, Error>

Return the number of keys strictly less than key.

Source

pub fn get_with<R>( &mut self, key: &[u8], read: impl FnOnce(&[u8]) -> R, ) -> Result<Option<R>, Error>

Read a value without copying it.

Source

pub fn get_lease( &mut self, key: &[u8], ) -> Result<Option<OwnedValueLease>, Error>

Retain the packed leaf containing a value beyond this borrowed session’s next traversal. Native adapters release the returned lease after their synchronous callback completes.

Source

pub fn get_value_ref_with<R>( &mut self, key: &[u8], read: impl for<'value> FnOnce(ValueRefView<'value>) -> R, ) -> Result<Option<R>, Error>

Inspect a stored large-value envelope without copying inline bytes.

Source

pub fn contains_key(&mut self, key: &[u8]) -> Result<bool, Error>

Check membership without copying the value.

Source

pub fn get_many_with<K, F>(&mut self, keys: &[K], visit: F) -> Result<(), Error>
where K: AsRef<[u8]>, F: for<'value> FnMut(usize, &[u8], Option<&'value [u8]>),

Visit point-read results exactly once per input position and in order.

Source

pub fn select_with<R>( &mut self, ordinal: u64, read: impl for<'entry> FnOnce(EntryRef<'entry>) -> R, ) -> Result<Option<R>, Error>

Visit the zero-based entry at ordinal without copying it.

Source

pub fn first_entry_with<R>( &mut self, read: impl for<'entry> FnOnce(EntryRef<'entry>) -> R, ) -> Result<Option<R>, Error>

Visit the first entry in key order.

Source

pub fn last_entry_with<R>( &mut self, read: impl for<'entry> FnOnce(EntryRef<'entry>) -> R, ) -> Result<Option<R>, Error>

Visit the last entry in key order.

Source

pub fn lower_bound_with<R>( &mut self, key: &[u8], read: impl for<'entry> FnOnce(EntryRef<'entry>) -> R, ) -> Result<Option<R>, Error>

Visit the first entry whose key is at least key.

Source

pub fn upper_bound_with<R>( &mut self, key: &[u8], read: impl for<'entry> FnOnce(EntryRef<'entry>) -> R, ) -> Result<Option<R>, Error>

Visit the first entry whose key is strictly greater than key.

Source

pub fn scan_range( &mut self, start: &[u8], end: Option<&[u8]>, visit: impl for<'entry> FnMut(EntryRef<'entry>), ) -> Result<u64, Error>

Visit a half-open range in ascending order.

Source

pub fn scan_range_until<B>( &mut self, start: &[u8], end: Option<&[u8]>, visit: impl for<'entry> FnMut(EntryRef<'entry>) -> ControlFlow<B>, ) -> Result<ScanOutcome<B>, Error>

Visit a half-open range in ascending order with early termination.

Source

pub fn scan_prefix( &mut self, prefix: &[u8], visit: impl for<'entry> FnMut(EntryRef<'entry>), ) -> Result<u64, Error>

Visit all entries under prefix in ascending order.

Source

pub fn scan_prefix_until<B>( &mut self, prefix: &[u8], visit: impl for<'entry> FnMut(EntryRef<'entry>) -> ControlFlow<B>, ) -> Result<ScanOutcome<B>, Error>

Visit all entries under prefix with early termination.

Source

pub fn scan_range_reverse( &mut self, start: &[u8], end: Option<&[u8]>, visit: impl for<'entry> FnMut(EntryRef<'entry>), ) -> Result<u64, Error>

Visit a half-open range in descending order.

Source

pub fn scan_range_reverse_until<B>( &mut self, start: &[u8], end: Option<&[u8]>, visit: impl for<'entry> FnMut(EntryRef<'entry>) -> ControlFlow<B>, ) -> Result<ScanOutcome<B>, Error>

Visit a half-open range in descending order with early termination.

Source

pub fn scan_prefix_reverse( &mut self, prefix: &[u8], visit: impl for<'entry> FnMut(EntryRef<'entry>), ) -> Result<u64, Error>

Visit a prefix in descending order.

Source

pub fn scan_prefix_reverse_until<B>( &mut self, prefix: &[u8], visit: impl for<'entry> FnMut(EntryRef<'entry>) -> ControlFlow<B>, ) -> Result<ScanOutcome<B>, Error>

Visit a prefix in descending order with early termination.

Auto Trait Implementations§

§

impl<'manager, 'tree, S> Freeze for ReadSession<'manager, 'tree, S>

§

impl<'manager, 'tree, S> RefUnwindSafe for ReadSession<'manager, 'tree, S>
where S: RefUnwindSafe,

§

impl<'manager, 'tree, S> Send for ReadSession<'manager, 'tree, S>

§

impl<'manager, 'tree, S> Sync for ReadSession<'manager, 'tree, S>

§

impl<'manager, 'tree, S> Unpin for ReadSession<'manager, 'tree, S>

§

impl<'manager, 'tree, S> UnsafeUnpin for ReadSession<'manager, 'tree, S>

§

impl<'manager, 'tree, S> UnwindSafe for ReadSession<'manager, 'tree, S>
where S: RefUnwindSafe,

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.