snarkvm_ledger_store::helpers

Trait Map

Source
pub trait Map<'a, K: 'a + Copy + Clone + PartialEq + Eq + Hash + Serialize + Deserialize<'a> + Send + Sync, V: 'a + Clone + PartialEq + Eq + Serialize + Deserialize<'a> + Send + Sync>:
    Clone
    + MapRead<'a, K, V>
    + Send
    + Sync {
    // Required methods
    fn insert(&self, key: K, value: V) -> Result<()>;
    fn remove(&self, 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<()>;
    fn pause_atomic_writes(&self) -> Result<()>;
    fn unpause_atomic_writes<const DISCARD_BATCH: bool>(&self) -> Result<()>;
}
Expand description

A trait representing map-like storage operations with read-write capabilities.

Required Methods§

Source

fn insert(&self, key: K, value: V) -> Result<()>

Inserts the given key-value pair into the map.

Source

fn remove(&self, key: &K) -> Result<()>

Removes the key-value pair for the given key from the map.

Source

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.

Source

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.

Source

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.

Source

fn clear_latest_checkpoint(&self)

Removes the latest atomic checkpoint.

Source

fn atomic_rewind(&self)

Removes all pending operations to the last atomic_checkpoint (or to start_atomic if no checkpoints have been created).

Source

fn abort_atomic(&self)

Aborts the current atomic operation.

Source

fn finish_atomic(&self) -> Result<()>

Finishes an atomic operation, performing all the queued writes.

Source

fn pause_atomic_writes(&self) -> Result<()>

Once called, the subsequent atomic write batches will be queued instead of being executed at the end of their scope. unpause_atomic_writes needs to be called in order to restore the usual behavior.

Source

fn unpause_atomic_writes<const DISCARD_BATCH: bool>(&self) -> Result<()>

Executes all of the queued writes as a single atomic operation and restores the usual behavior of atomic write batches that was altered by calling pause_atomic_writes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, K: 'a + Copy + Clone + PartialEq + Eq + Hash + Serialize + for<'de> Deserialize<'de> + Send + Sync, V: 'a + Clone + PartialEq + Eq + Serialize + for<'de> Deserialize<'de> + Send + Sync> Map<'a, K, V> for MemoryMap<K, V>