Trait snarkvm_ledger_store::helpers::NestedMap
source · pub trait NestedMap<'a, M: 'a + Copy + Clone + PartialEq + Eq + Hash + Serialize + Deserialize<'a> + Send + Sync, K: 'a + Clone + PartialEq + Eq + Serialize + Deserialize<'a> + Send + Sync, V: 'a + Clone + PartialEq + Eq + Serialize + Deserialize<'a> + Send + Sync>: Clone + NestedMapRead<'a, M, K, V> + Send + Sync {
// Required methods
fn insert(&self, map: M, key: K, value: V) -> Result<()>;
fn remove_map(&self, map: &M) -> Result<()>;
fn remove_key(&self, map: &M, key: &K) -> Result<()>;
fn start_atomic(&self);
fn is_atomic_in_progress(&self) -> bool;
fn atomic_checkpoint(&self);
fn clear_latest_checkpoint(&self);
fn atomic_rewind(&self);
fn abort_atomic(&self);
fn finish_atomic(&self) -> Result<()>;
}
Expand description
A trait representing ‘nested map’-like storage operations with read-write capabilities.
Required Methods§
sourcefn remove_map(&self, map: &M) -> Result<()>
fn remove_map(&self, map: &M) -> Result<()>
Removes the given map.
sourcefn remove_key(&self, map: &M, key: &K) -> Result<()>
fn remove_key(&self, map: &M, key: &K) -> Result<()>
Removes the key-value pair for the given map and key.
sourcefn start_atomic(&self)
fn start_atomic(&self)
Begins an atomic operation. Any further calls to insert
and remove
will be queued
without an actual write taking place until finish_atomic
is called.
sourcefn is_atomic_in_progress(&self) -> bool
fn is_atomic_in_progress(&self) -> bool
Checks whether an atomic operation is currently in progress. This can be done to ensure that lower-level operations don’t start or finish their individual atomic write batch if they are already part of a larger one.
sourcefn atomic_checkpoint(&self)
fn atomic_checkpoint(&self)
Saves the current list of pending operations, so that if atomic_rewind
is called,
we roll back all future operations, and return to the start of this checkpoint.
sourcefn clear_latest_checkpoint(&self)
fn clear_latest_checkpoint(&self)
Removes the latest atomic checkpoint.
sourcefn atomic_rewind(&self)
fn atomic_rewind(&self)
Removes all pending operations to the last atomic_checkpoint
(or to start_atomic
if no checkpoints have been created).
sourcefn abort_atomic(&self)
fn abort_atomic(&self)
Aborts the current atomic operation.
sourcefn finish_atomic(&self) -> Result<()>
fn finish_atomic(&self) -> Result<()>
Finishes an atomic operation, performing all the queued writes.