miden_crypto::utils::collections

Struct RecordingMap

source
pub struct RecordingMap<K, V> { /* private fields */ }
Expand description

A RecordingMap that records read requests to the underlying key-value map.

The data recorder is used to generate a proof for read requests.

The RecordingMap is composed of three parts:

  • data: which contains the current set of key-value pairs in the map.
  • updates: which tracks keys for which values have been changed since the map was instantiated. updates include both insertions, removals and updates of values under existing keys.
  • trace: which contains the key-value pairs from the original data which have been accesses since the map was instantiated.

Implementations§

source§

impl<K: Ord + Clone, V: Clone> RecordingMap<K, V>

source

pub fn new(init: impl IntoIterator<Item = (K, V)>) -> Self

Returns a new RecordingMap instance initialized with the provided key-value pairs. (BTreeMap).

source

pub fn inner(&self) -> &BTreeMap<K, V>

source

pub fn finalize(self) -> (BTreeMap<K, V>, BTreeMap<K, V>)

Consumes the RecordingMap and returns a (BTreeMap, BTreeMap) tuple. The first element of the tuple is a map that represents the state of the map at the time .finalize() is called. The second element contains the key-value pairs from the initial data set that were read during recording.

Trait Implementations§

source§

impl<K: Clone, V: Clone> Clone for RecordingMap<K, V>

source§

fn clone(&self) -> RecordingMap<K, V>

Returns a copy of the value. Read more
1.6.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<K: Debug, V: Debug> Debug for RecordingMap<K, V>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<K: Default, V: Default> Default for RecordingMap<K, V>

source§

fn default() -> RecordingMap<K, V>

Returns the “default value” for a type. Read more
source§

impl<K: Clone + Ord, V: Clone> Extend<(K, V)> for RecordingMap<K, V>

source§

fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<K: Clone + Ord, V: Clone> FromIterator<(K, V)> for RecordingMap<K, V>

source§

fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<K: Clone + Ord, V: Clone> IntoIterator for RecordingMap<K, V>

source§

type Item = (K, V)

The type of the elements being iterated over.
source§

type IntoIter = IntoIter<K, V>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<K: Ord + Clone, V: Clone> KvMap<K, V> for RecordingMap<K, V>

source§

fn get(&self, key: &K) -> Option<&V>

Returns a reference to the value associated with the given key if the value exists.

If the key is part of the initial data set, the key access is recorded.

source§

fn contains_key(&self, key: &K) -> bool

Returns a boolean to indicate whether the given key exists in the data set.

If the key is part of the initial data set, the key access is recorded.

source§

fn len(&self) -> usize

Returns the number of key-value pairs in the data set.

source§

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

Inserts a key-value pair into the data set.

If the key already exists in the data set, the value is updated and the old value is returned.

source§

fn remove(&mut self, key: &K) -> Option<V>

Removes a key-value pair from the data set.

If the key exists in the data set, the old value is returned.

source§

fn iter(&self) -> Box<dyn Iterator<Item = (&K, &V)> + '_>

Returns an iterator over the key-value pairs in the data set.

source§

fn is_empty(&self) -> bool

source§

impl<K: PartialEq, V: PartialEq> PartialEq for RecordingMap<K, V>

source§

fn eq(&self, other: &RecordingMap<K, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.6.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K: Eq, V: Eq> Eq for RecordingMap<K, V>

source§

impl<K, V> StructuralPartialEq for RecordingMap<K, V>

Auto Trait Implementations§

§

impl<K, V> !Freeze for RecordingMap<K, V>

§

impl<K, V> !RefUnwindSafe for RecordingMap<K, V>

§

impl<K, V> Send for RecordingMap<K, V>
where K: Send, V: Send,

§

impl<K, V> !Sync for RecordingMap<K, V>

§

impl<K, V> Unpin for RecordingMap<K, V>

§

impl<K, V> UnwindSafe for RecordingMap<K, V>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V