Skip to main content

TrieDiff

Struct TrieDiff 

Source
pub struct TrieDiff<T = ()> { /* private fields */ }

Implementations§

Source§

impl<T> TrieDiff<T>

Source

pub fn empty() -> Self

Builds a new empty diff.

Source

pub fn clear(&mut self)

Removes all the entries within this diff.

Source

pub fn diff_insert( &mut self, key: impl Into<Vec<u8>>, value: impl Into<Vec<u8>>, user_data: T, ) -> Option<(Option<Vec<u8>>, T)>

Inserts the given key-value combination in the diff.

Returns the value associated to this key that was previously in the diff, if any.

Source

pub fn diff_insert_erase( &mut self, key: impl Into<Vec<u8>>, user_data: T, ) -> Option<(Option<Vec<u8>>, T)>

Inserts in the diff an entry at the given key that delete the value that is located in the base storage.

Returns the value associated to this key that was previously in the diff, if any.

Source

pub fn diff_remove( &mut self, key: impl AsRef<[u8]>, ) -> Option<(Option<Vec<u8>>, T)>

Removes from the diff the entry corresponding to the given key.

Returns the value associated to this key that was previously in the diff, if any.

Source

pub fn diff_get(&self, key: &[u8]) -> Option<(Option<&[u8]>, &T)>

Returns the diff entry at the given key.

Returns None if the diff doesn’t have any entry for this key, and Some((None, _)) if the diff has an entry that deletes the storage item.

Source

pub fn diff_iter_unordered( &self, ) -> impl ExactSizeIterator<Item = (&[u8], Option<&[u8]>, &T)> + Clone

Returns an iterator to all the entries in the diff.

Each value is either Some if the diff overwrites this diff, or None if it erases the underlying value.

Source

pub fn diff_into_iter_unordered( self, ) -> impl ExactSizeIterator<Item = (Vec<u8>, Option<Vec<u8>>, T)>

Returns an iterator to all the entries in the diff.

Each value is either Some if the diff overwrites this diff, or None if it erases the underlying value.

Source

pub fn diff_range_ordered<U>( &self, range: impl RangeBounds<U>, ) -> impl Iterator<Item = (&[u8], bool)> + Clone
where U: Ord + ?Sized, Vec<u8>: Borrow<U>,

Returns an iterator to all the entries in the diff within a given range.

Each iterator element is the given and a boolean. This boolean is true if the diff overwrites this entry, or false if it erases the underlying value.

Source

pub fn storage_next_key<'a>( &'a self, key: &[u8], in_parent_next_key: Option<&'a [u8]>, or_equal: bool, ) -> StorageNextKey<'a>

Returns the storage key that immediately follows the provided key. Must be passed the storage key that immediately follows the provided key according to the base storage this diff is based upon.

If StorageNextKey::Found is returned, it contains the desired key. If StorageNextKey::NextOf is returned, then this function should be called again but by passing the key found in the StorageNextKey::NextOf (and of course the corresponding in_parent_next_key).

§Panic

Panics if in_parent_next_key is provided and is inferior or equal to key.

Source

pub fn merge(&mut self, other: &TrieDiff<T>)
where T: Clone,

Applies the given diff on top of the current one.

Source

pub fn merge_map<U>(&mut self, other: &TrieDiff<U>, map: impl FnMut(&U) -> T)

Applies the given diff on top of the current one.

Each user data in the other diff is first passed through the map.

Trait Implementations§

Source§

impl<T: Clone> Clone for TrieDiff<T>

Source§

fn clone(&self) -> TrieDiff<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for TrieDiff<T>
where T: Debug,

Source§

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

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

impl<T> Default for TrieDiff<T>

Source§

fn default() -> Self

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

impl<T> FromIterator<(Vec<u8>, Option<Vec<u8>>, T)> for TrieDiff<T>

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = (Vec<u8>, Option<Vec<u8>>, T)>,

Creates a value from an iterator. Read more
Source§

impl<T, U> PartialEq<TrieDiff<U>> for TrieDiff<T>
where T: PartialEq<U>,

Source§

fn eq(&self, other: &TrieDiff<U>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.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<T> Eq for TrieDiff<T>
where T: Eq,

Auto Trait Implementations§

§

impl<T> Freeze for TrieDiff<T>

§

impl<T> RefUnwindSafe for TrieDiff<T>
where T: RefUnwindSafe,

§

impl<T> Send for TrieDiff<T>
where T: Send,

§

impl<T> Sync for TrieDiff<T>
where T: Sync,

§

impl<T> Unpin for TrieDiff<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TrieDiff<T>

§

impl<T> UnwindSafe for TrieDiff<T>
where T: UnwindSafe,

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, dest: *mut u8)

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

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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