snarkvm_ledger_store::helpers

Trait NestedMapRead

Source
pub trait NestedMapRead<'a, M: 'a + Copy + Clone + PartialEq + Eq + Hash + Serialize + Deserialize<'a> + Sync, K: 'a + Clone + PartialEq + Eq + Serialize + Deserialize<'a> + Sync, V: 'a + Clone + PartialEq + Eq + Serialize + Deserialize<'a> + Sync> {
    type PendingIterator: Iterator<Item = (Cow<'a, M>, Option<Cow<'a, K>>, Option<Cow<'a, V>>)>;
    type Iterator: Iterator<Item = (Cow<'a, M>, Cow<'a, K>, Cow<'a, V>)>;
    type Keys: Iterator<Item = (Cow<'a, M>, Cow<'a, K>)>;
    type Values: Iterator<Item = Cow<'a, V>>;

Show 13 methods // Required methods fn len_map_confirmed(&self, map: &M) -> Result<usize>; fn contains_key_confirmed(&self, map: &M, key: &K) -> Result<bool>; fn contains_key_speculative(&self, map: &M, key: &K) -> Result<bool>; fn get_map_confirmed(&'a self, map: &M) -> Result<Vec<(K, V)>>; fn get_map_speculative(&'a self, map: &M) -> Result<Vec<(K, V)>>; fn get_value_confirmed( &'a self, map: &M, key: &K, ) -> Result<Option<Cow<'a, V>>>; fn get_value_pending(&self, map: &M, key: &K) -> Option<Option<V>>; fn iter_pending(&'a self) -> Self::PendingIterator; fn iter_confirmed(&'a self) -> Self::Iterator; fn keys_confirmed(&'a self) -> Self::Keys; fn values_confirmed(&'a self) -> Self::Values; // Provided methods fn is_empty_map_confirmed(&self, map: &M) -> Result<bool> { ... } fn get_value_speculative( &'a self, map: &M, key: &K, ) -> Result<Option<Cow<'a, V>>> { ... }
}
Expand description

A trait representing ‘nested map’-like storage operations with read-only capabilities.

Required Associated Types§

Source

type PendingIterator: Iterator<Item = (Cow<'a, M>, Option<Cow<'a, K>>, Option<Cow<'a, V>>)>

Source

type Iterator: Iterator<Item = (Cow<'a, M>, Cow<'a, K>, Cow<'a, V>)>

Source

type Keys: Iterator<Item = (Cow<'a, M>, Cow<'a, K>)>

Source

type Values: Iterator<Item = Cow<'a, V>>

Required Methods§

Source

fn len_map_confirmed(&self, map: &M) -> Result<usize>

Returns the number of confirmed entries in the map.

Source

fn contains_key_confirmed(&self, map: &M, key: &K) -> Result<bool>

Returns true if the given key exists in the map.

Source

fn contains_key_speculative(&self, map: &M, key: &K) -> Result<bool>

Returns true if the given key exists in the map. This method first checks the atomic batch, and if it does not exist, then checks the confirmed.

Source

fn get_map_confirmed(&'a self, map: &M) -> Result<Vec<(K, V)>>

Returns the confirmed key-value pairs for the given map, if it exists.

Source

fn get_map_speculative(&'a self, map: &M) -> Result<Vec<(K, V)>>

Returns the speculative key-value pairs for the given map, if it exists.

Source

fn get_value_confirmed(&'a self, map: &M, key: &K) -> Result<Option<Cow<'a, V>>>

Returns the value for the given key from the map, if it exists.

Source

fn get_value_pending(&self, map: &M, key: &K) -> Option<Option<V>>

Returns the current value for the given key if it is scheduled to be inserted as part of an atomic batch.

If the key does not exist, returns None. If the key is removed in the batch, returns Some(None). If the key is inserted in the batch, returns Some(Some(value)).

Source

fn iter_pending(&'a self) -> Self::PendingIterator

Returns an iterator visiting each map-key-value pair in the atomic batch.

Source

fn iter_confirmed(&'a self) -> Self::Iterator

Returns an iterator visiting each confirmed map-key-value pair.

Source

fn keys_confirmed(&'a self) -> Self::Keys

Returns an iterator over each confirmed key.

Source

fn values_confirmed(&'a self) -> Self::Values

Returns an iterator over each confirmed value.

Provided Methods§

Source

fn is_empty_map_confirmed(&self, map: &M) -> Result<bool>

Checks whether there are any confirmed entries in the map.

Source

fn get_value_speculative( &'a self, map: &M, key: &K, ) -> Result<Option<Cow<'a, V>>>

Returns the value for the given key from the atomic batch first, if it exists, or return from the map, otherwise.

Implementors§

Source§

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

Source§

type Iterator = IntoIter<(Cow<'a, M>, Cow<'a, K>, Cow<'a, V>)>

Source§

type Keys = IntoIter<(Cow<'a, M>, Cow<'a, K>)>

Source§

type PendingIterator = Map<IntoIter<(M, Option<K>, Option<V>)>, fn(_: (M, Option<K>, Option<V>)) -> (Cow<'a, M>, Option<Cow<'a, K>>, Option<Cow<'a, V>>)>

Source§

type Values = Map<IntoValues<Vec<u8>, V>, fn(_: V) -> Cow<'a, V>>