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: TreeThe sled::Tree that is being overlayed.
state: SledTreeOverlayStateCurrent overlay cache state.
Implementations§
Source§impl SledTreeOverlay
impl SledTreeOverlay
Sourcepub fn new(tree: &Tree) -> Self
pub fn new(tree: &Tree) -> Self
Instantiate a new SledTreeOverlay on top of a given sled::Tree.
Sourcepub fn contains_key(&self, key: &[u8]) -> Result<bool, Error>
pub fn contains_key(&self, key: &[u8]) -> Result<bool, Error>
Returns true if the overlay contains a value for a specified key.
Sourcepub fn last(&self) -> Result<Option<(IVec, IVec)>, Error>
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>.
Sourcepub fn get(&self, key: &[u8]) -> Result<Option<IVec>, Error>
pub fn get(&self, key: &[u8]) -> Result<Option<IVec>, Error>
Retrieve a value from the overlay if it exists.
Sourcepub fn insert(
&mut self,
key: &[u8],
value: &[u8],
) -> Result<Option<IVec>, Error>
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.
Sourcepub fn remove(&mut self, key: &[u8]) -> Result<Option<IVec>, Error>
pub fn remove(&mut self, key: &[u8]) -> Result<Option<IVec>, Error>
Delete a value, if it exists, returning the old value.
Sourcepub fn clear(&mut self) -> Result<(), Error>
pub fn clear(&mut self) -> Result<(), Error>
Removes all values from the cache and marks all tree records as removed.
Sourcepub fn aggregate(&self) -> Option<Batch>
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.
Sourcepub fn checkpoint(&mut self)
pub fn checkpoint(&mut self)
Checkpoint current cache state so we can revert to it, if needed.
Sourcepub fn revert_to_checkpoint(&mut self)
pub fn revert_to_checkpoint(&mut self)
Revert to current cache state checkpoint.
Sourcepub fn diff(
&self,
sequence: &[SledTreeOverlayStateDiff],
) -> Result<SledTreeOverlayStateDiff, Error>
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.
Sourcepub fn add_diff(&mut self, diff: &SledTreeOverlayStateDiff)
pub fn add_diff(&mut self, diff: &SledTreeOverlayStateDiff)
Add provided tree overlay state changes from our own.
Sourcepub fn remove_diff(&mut self, diff: &SledTreeOverlayStateDiff)
pub fn remove_diff(&mut self, diff: &SledTreeOverlayStateDiff)
Remove provided tree overlay state changes from our own.
Sourcepub fn iter(&self) -> SledTreeOverlayIter<'_> ⓘ
pub fn iter(&self) -> SledTreeOverlayIter<'_> ⓘ
Immutably iterate through the tree overlay.
Trait Implementations§
Source§impl Clone for SledTreeOverlay
impl Clone for SledTreeOverlay
Source§fn clone(&self) -> SledTreeOverlay
fn clone(&self) -> SledTreeOverlay
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SledTreeOverlay
impl Debug for SledTreeOverlay
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.
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.