Struct everscale_types::dict::Dict
source · pub struct Dict<K, V> { /* private fields */ }Expand description
Typed dictionary with fixed length keys.
Implementations§
source§impl<K, V> Dict<K, V>where
K: Store + DictKey,
impl<K, V> Dict<K, V>where K: Store + DictKey,
sourcepub fn get<'a: 'b, 'b, Q>(&'a self, key: Q) -> Result<Option<V>, Error>where
Q: Borrow<K> + 'b,
V: Load<'a>,
pub fn get<'a: 'b, 'b, Q>(&'a self, key: Q) -> Result<Option<V>, Error>where Q: Borrow<K> + 'b, V: Load<'a>,
Returns the value corresponding to the key.
Key is serialized using the default finalizer.
sourcepub fn get_raw<'a: 'b, 'b, Q>(
&'a self,
key: Q
) -> Result<Option<CellSlice<'a>>, Error>where
Q: Borrow<K> + 'b,
pub fn get_raw<'a: 'b, 'b, Q>( &'a self, key: Q ) -> Result<Option<CellSlice<'a>>, Error>where Q: Borrow<K> + 'b,
Returns the raw value corresponding to the key.
Key is serialized using the default finalizer.
sourcepub fn remove<Q>(&mut self, key: Q) -> Result<Option<V>, Error>where
Q: Borrow<K>,
for<'a> V: Load<'a> + 'static,
pub fn remove<Q>(&mut self, key: Q) -> Result<Option<V>, Error>where Q: Borrow<K>, for<'a> V: Load<'a> + 'static,
Removes the value associated with key in dictionary. Returns an optional removed value.
Key is serialized using the default finalizer.
sourcepub fn remove_raw<Q>(&mut self, key: Q) -> Result<Option<CellSliceParts>, Error>where
Q: Borrow<K>,
pub fn remove_raw<Q>(&mut self, key: Q) -> Result<Option<CellSliceParts>, Error>where Q: Borrow<K>,
Removes the value associated with key in dictionary. Returns an optional removed value as cell slice parts.
Key is serialized using the default finalizer.
source§impl<K, V> Dict<K, V>where
K: Store + DictKey,
V: Store,
impl<K, V> Dict<K, V>where K: Store + DictKey, V: Store,
sourcepub fn set<Q, T>(&mut self, key: Q, value: T) -> Result<(), Error>where
Q: Borrow<K>,
T: Borrow<V>,
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§impl<K, V> Dict<K, V>where
K: Store + DictKey,
impl<K, V> Dict<K, V>where K: Store + DictKey,
sourcepub fn iter<'a>(&'a self) -> Iter<'_, K, V> ⓘwhere
V: Load<'a>,
pub fn iter<'a>(&'a self) -> Iter<'_, K, V> ⓘwhere V: Load<'a>,
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.
sourcepub fn keys(&self) -> Keys<'_, K> ⓘ
pub fn keys(&self) -> Keys<'_, 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<K, V> Dict<K, V>where
K: Store + DictKey,
impl<K, V> Dict<K, V>where K: Store + DictKey,
sourcepub fn get_ext<'a: 'b, 'b, Q>(
&'a self,
key: Q,
finalizer: &mut dyn Finalizer
) -> Result<Option<V>, Error>where
Q: Borrow<K> + 'b,
V: Load<'a>,
pub fn get_ext<'a: 'b, 'b, Q>( &'a self, key: Q, finalizer: &mut dyn Finalizer ) -> Result<Option<V>, Error>where Q: Borrow<K> + 'b, V: Load<'a>,
Returns the value corresponding to the key.
Key is serialized using the provided finalizer.
sourcepub fn get_raw_ext<'a: 'b, 'b, Q>(
&'a self,
key: Q,
finalizer: &mut dyn Finalizer
) -> Result<Option<CellSlice<'a>>, Error>where
Q: Borrow<K> + 'b,
pub fn get_raw_ext<'a: 'b, 'b, Q>( &'a self, key: Q, finalizer: &mut dyn Finalizer ) -> Result<Option<CellSlice<'a>>, Error>where Q: Borrow<K> + 'b,
Returns the value corresponding to the key.
Key is serialized using the provided finalizer.
sourcepub fn remove_raw_ext<Q>(
&mut self,
key: Q,
finalizer: &mut dyn Finalizer
) -> Result<Option<CellSliceParts>, Error>where
Q: Borrow<K>,
pub fn remove_raw_ext<Q>( &mut self, key: Q, finalizer: &mut dyn Finalizer ) -> Result<Option<CellSliceParts>, Error>where Q: Borrow<K>,
Removes the value associated with key in dictionary. Returns an optional removed value as cell slice parts.
Key is serialized using the provided finalizer.
sourcepub fn raw_iter(&self) -> RawIter<'_> ⓘ
pub fn raw_iter(&self) -> RawIter<'_> ⓘ
Gets an iterator over the raw entries of the dictionary, sorted by key.
The iterator element type is Result<(CellBuilder, CellSlice)>.
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.
sourcepub fn raw_keys(&self) -> RawKeys<'_> ⓘ
pub fn raw_keys(&self) -> RawKeys<'_> ⓘ
Gets an iterator over the raw keys of the dictionary, in sorted order.
The iterator element type is Result<CellBuilder>.
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<K, V> Dict<K, V>where
K: DictKey,
impl<K, V> Dict<K, V>where K: DictKey,
sourcepub fn raw_values(&self) -> RawValues<'_> ⓘ
pub fn raw_values(&self) -> RawValues<'_> ⓘ
Gets an iterator over the raw values of the dictionary, in order by key.
The iterator element type is Result<CellSlice>.
If the dictionary is invalid, finishes after the first invalid element, returning an error.
source§impl<K, V> Dict<K, V>where
K: Store + DictKey,
V: Store,
impl<K, V> Dict<K, V>where K: Store + DictKey, V: Store,
sourcepub fn set_ext<Q, T>(
&mut self,
key: Q,
value: T,
finalizer: &mut dyn Finalizer
) -> Result<(), Error>where
Q: Borrow<K>,
T: Borrow<V>,
pub fn set_ext<Q, T>( &mut self, key: Q, value: T, finalizer: &mut dyn Finalizer ) -> Result<(), Error>where Q: Borrow<K>, T: Borrow<V>,
Sets the value associated with the key in the dictionary.