SledTreeOverlay

Struct SledTreeOverlay 

Source
pub struct SledTreeOverlay {
    pub tree: Tree,
    pub state: SledTreeOverlayState,
    /* private fields */
}
Expand description

An overlay on top of a single sled::Tree instance.

Fields§

§tree: Tree

The sled::Tree that is being overlayed.

§state: SledTreeOverlayState

Current overlay cache state.

Implementations§

Source§

impl SledTreeOverlay

Source

pub fn new(tree: &Tree) -> Self

Instantiate a new SledTreeOverlay on top of a given sled::Tree.

Source

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

Returns true if the overlay contains a value for a specified key.

Source

pub fn is_empty(&self) -> bool

Returns true if the overlay is empty.

Source

pub fn last(&self) -> Result<Option<(IVec, IVec)>, Error>

Returns last key and value from the overlay or None if its empty, based on the Ord implementation for Vec<u8>.

Source

pub fn get(&self, key: &[u8]) -> Result<Option<IVec>, Error>

Retrieve a value from the overlay if it exists.

Source

pub fn insert( &mut self, key: &[u8], value: &[u8], ) -> Result<Option<IVec>, Error>

Insert a key to a new value, returning the last value if it was set.

Source

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

Delete a value, if it exists, returning the old value.

Source

pub fn clear(&mut self) -> Result<(), Error>

Removes all values from the cache and marks all tree records as removed.

Source

pub fn aggregate(&self) -> Option<Batch>

Aggregate all the current overlay changes into a sled::Batch ready for further operation. If there are no changes, return None.

Source

pub fn checkpoint(&mut self)

Checkpoint current cache state so we can revert to it, if needed.

Source

pub fn revert_to_checkpoint(&mut self)

Revert to current cache state checkpoint.

Source

pub fn diff( &self, sequence: &[SledTreeOverlayStateDiff], ) -> Result<SledTreeOverlayStateDiff, Error>

Calculate differences from provided overlay state changes sequence. This can be used when we want to keep track of consecutive individual changes performed over the current overlay state. If the sequence is empty, current state is returned as the diff.

Source

pub fn add_diff(&mut self, diff: &SledTreeOverlayStateDiff)

Add provided tree overlay state changes from our own.

Source

pub fn remove_diff(&mut self, diff: &SledTreeOverlayStateDiff)

Remove provided tree overlay state changes from our own.

Source

pub fn iter(&self) -> SledTreeOverlayIter<'_>

Immutably iterate through the tree overlay.

Trait Implementations§

Source§

impl Clone for SledTreeOverlay

Source§

fn clone(&self) -> SledTreeOverlay

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 Debug for SledTreeOverlay

Source§

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

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

impl<'a> IntoIterator for &'a SledTreeOverlay

Define fusion iteration behavior, allowing us to use the SledTreeOverlayIter iterator in loops directly, without using .iter() method of SledTreeOverlay.

Source§

type Item = Result<(IVec, IVec), Error>

The type of the elements being iterated over.
Source§

type IntoIter = SledTreeOverlayIter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

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