Struct sled_overlay::tree::SledTreeOverlay
source · pub struct SledTreeOverlay {
pub state: SledTreeOverlayState,
/* private fields */
}Expand description
An overlay on top of a single sled::Tree instance
Fields§
§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 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: &[SledTreeOverlayState]) -> SledTreeOverlayState
pub fn diff(&self, sequence: &[SledTreeOverlayState]) -> SledTreeOverlayState
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, other: &SledTreeOverlayState)
pub fn add_diff(&mut self, other: &SledTreeOverlayState)
Add provided tree overlay state changes from our own.
sourcepub fn remove_diff(&mut self, other: &SledTreeOverlayState)
pub fn remove_diff(&mut self, other: &SledTreeOverlayState)
Remove provided tree overlay state changes from our own.
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 more