Struct everscale_types::dict::Dict

source ·
pub struct Dict<C: CellFamily, K, V> { /* private fields */ }
Expand description

Typed dictionary with fixed length keys.

Implementations§

source§

impl<C: CellFamily, K, V> Dict<C, K, V>

source

pub const fn new() -> Self

Creates an empty dictionary

source

pub const fn is_empty(&self) -> bool

Returns true if the dictionary contains no elements.

source

pub const fn root(&self) -> &Option<CellContainer<C>>

Returns the underlying root cell of the dictionary.

source§

impl<C, K, V> Dict<C, K, V>where for<'c> C: CellFamily + 'c, K: DictKey,

source

pub fn load_from_root_ext( slice: &mut CellSlice<'_, C>, finalizer: &mut dyn Finalizer<C> ) -> Option<Self>

Loads a non-empty dictionary from a root cell.

source§

impl<C, K, V> Dict<C, K, V>where for<'c> C: DefaultFinalizer + 'c, K: Store<C> + DictKey,

source

pub fn contains_key<Q>(&self, key: Q) -> Result<bool, Error>where Q: Borrow<K>,

Returns true if the dictionary contains a value for the specified key.

source§

impl<C, K, V> Dict<C, K, V>where for<'c> C: DefaultFinalizer + 'c, K: Store<C> + DictKey,

source

pub fn get<'a: 'b, 'b, Q>(&'a self, key: Q) -> Result<Option<V>, Error>where Q: Borrow<K> + 'b, V: Load<'a, C>,

Returns the value corresponding to the key.

Key is serialized using the default finalizer.

source

pub fn get_raw<'a: 'b, 'b, Q>( &'a self, key: Q ) -> Result<Option<CellSlice<'a, C>>, Error>where Q: Borrow<K> + 'b,

Returns the raw value corresponding to the key.

Key is serialized using the default finalizer.

source§

impl<C, K, V> Dict<C, K, V>where for<'c> C: DefaultFinalizer + 'c, K: Store<C> + DictKey, V: Store<C>,

source

pub fn set<Q, T>(&mut self, key: Q, value: T) -> Result<(), Error>where Q: Borrow<K>, T: Borrow<V>,

Sets the value associated with the key in the dictionary.

Use set_ext if you need to use a custom finalizer.

source

pub fn replace<Q, T>(&mut self, key: Q, value: T) -> Result<(), Error>where Q: Borrow<K>, T: Borrow<V>,

Sets the value associated with the key in the dictionary only if the key was already present in it.

Use replace_ext if you need to use a custom finalizer.

source

pub fn add<Q, T>(&mut self, key: Q, value: T) -> Result<(), Error>where Q: Borrow<K>, T: Borrow<V>,

Sets the value associated with key in dictionary, but only if it is not already present.

Use add_ext if you need to use a custom finalizer.

source§

impl<C: CellFamily, K, V> Dict<C, K, V>where K: Store<C> + DictKey,

source

pub fn iter<'a>(&'a self) -> Iter<'_, C, K, V> where V: Load<'a, C>,

Gets an iterator over the entries of the dictionary, sorted by key. The iterator element type is Result<(K, V)>.

If the dictionary is invalid, finishes after the first invalid element, returning an error.

Performance

In the current implementation, iterating over dictionary builds a key for each element. Use values or raw_values if you don’t need keys from an iterator.

source

pub fn keys(&self) -> Keys<'_, C, K>

Gets an iterator over the keys of the dictionary, in sorted order. The iterator element type is Result<K>.

If the dictionary is invalid, finishes after the first invalid element, returning an error.

Performance

In the current implementation, iterating over dictionary builds a key for each element. Use values if you don’t need keys from an iterator.

source§

impl<C, K, V> Dict<C, K, V>where for<'c> C: DefaultFinalizer + 'c, K: DictKey,

source

pub fn values<'a>(&'a self) -> Values<'a, C, V> where V: Load<'a, C>,

Gets an iterator over the values of the dictionary, in order by key. The iterator element type is Result<V>.

If the dictionary is invalid, finishes after the first invalid element, returning an error.

source§

impl<C, K, V> Dict<C, K, V>where for<'c> C: CellFamily + 'c, K: Store<C> + DictKey,

source

pub fn get_ext<'a: 'b, 'b, Q>( &'a self, key: Q, finalizer: &mut dyn Finalizer<C> ) -> Result<Option<V>, Error>where Q: Borrow<K> + 'b, V: Load<'a, C>,

Returns the value corresponding to the key.

Key is serialized using the provided finalizer.

source

pub fn get_raw_ext<'a: 'b, 'b, Q>( &'a self, key: Q, finalizer: &mut dyn Finalizer<C> ) -> Result<Option<CellSlice<'a, C>>, Error>where Q: Borrow<K> + 'b,

Returns the value corresponding to the key.

Key is serialized using the provided finalizer.

source

pub fn raw_iter(&self) -> RawIter<'_, C>

Gets an iterator over the raw entries of the dictionary, sorted by key. The iterator element type is Result<(CellBuilder<C>, CellSlice<C>)>.

If the dictionary is invalid, finishes after the first invalid element, returning an error.

Performance

In the current implementation, iterating over dictionary builds a key for each element. Use values or raw_values if you don’t need keys from an iterator.

source

pub fn raw_keys(&self) -> RawKeys<'_, C>

Gets an iterator over the raw keys of the dictionary, in sorted order. The iterator element type is Result<CellBuilder<C>>.

If the dictionary is invalid, finishes after the first invalid element, returning an error.

Performance

In the current implementation, iterating over dictionary builds a key for each element. Use values or raw_values if you don’t need keys from an iterator.

source§

impl<C, K, V> Dict<C, K, V>where for<'c> C: CellFamily + 'c, K: DictKey,

source

pub fn raw_values(&self) -> RawValues<'_, C>

Gets an iterator over the raw values of the dictionary, in order by key. The iterator element type is Result<CellSlice<C>>.

If the dictionary is invalid, finishes after the first invalid element, returning an error.

source§

impl<C, K, V> Dict<C, K, V>where for<'c> C: CellFamily + 'c, K: Store<C> + DictKey, V: Store<C>,

source

pub fn set_ext<Q, T>( &mut self, key: Q, value: T, finalizer: &mut dyn Finalizer<C> ) -> Result<(), Error>where Q: Borrow<K>, T: Borrow<V>,

Sets the value associated with the key in the dictionary.

source

pub fn replace_ext<Q, T>( &mut self, key: Q, value: T, finalizer: &mut dyn Finalizer<C> ) -> Result<(), Error>where Q: Borrow<K>, T: Borrow<V>,

Sets the value associated with the key in the dictionary only if the key was already present in it.

source

pub fn add_ext<Q, T>( &mut self, key: Q, value: T, finalizer: &mut dyn Finalizer<C> ) -> Result<(), Error>where Q: Borrow<K>, T: Borrow<V>,

Sets the value associated with key in dictionary, but only if it is not already present.

Trait Implementations§

source§

impl<C: CellFamily, K, V> Clone for Dict<C, K, V>

source§

fn clone(&self) -> Self

Returns a copy 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<C: CellFamily, K, V> Debug for Dict<C, K, V>

source§

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

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

impl<C: CellFamily, K, V> Default for Dict<C, K, V>

source§

fn default() -> Self

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

impl<C: CellFamily, K, V> From<Option<<C as CellFamily>::Container>> for Dict<C, K, V>

source§

fn from(dict: Option<CellContainer<C>>) -> Self

Converts to this type from the input type.
source§

impl<'a, C: CellFamily, K, V> Load<'a, C> for Dict<C, K, V>

source§

fn load_from(slice: &mut CellSlice<'a, C>) -> Option<Self>

Tries to load itself from a cell slice.
source§

impl<C: CellFamily, K, V> PartialEq<Dict<C, K, V>> for Dict<C, K, V>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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

impl<C: CellFamily, K, V> Store<C> for Dict<C, K, V>

source§

fn store_into( &self, builder: &mut CellBuilder<C>, finalizer: &mut dyn Finalizer<C> ) -> bool

Tries to store itself into the cell builder.
source§

impl<C: CellFamily, K, V> Eq for Dict<C, K, V>

Auto Trait Implementations§

§

impl<C, K, V> RefUnwindSafe for Dict<C, K, V>where K: RefUnwindSafe, V: RefUnwindSafe, <C as CellFamily>::Container: RefUnwindSafe,

§

impl<C, K, V> Send for Dict<C, K, V>where K: Send, V: Send, <C as CellFamily>::Container: Send,

§

impl<C, K, V> Sync for Dict<C, K, V>where K: Sync, V: Sync, <C as CellFamily>::Container: Sync,

§

impl<C, K, V> Unpin for Dict<C, K, V>where K: Unpin, V: Unpin, <C as CellFamily>::Container: Unpin,

§

impl<C, K, V> UnwindSafe for Dict<C, K, V>where K: UnwindSafe, V: UnwindSafe, <C as CellFamily>::Container: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.