Enum concordium_std::Entry
source · pub enum Entry<'a, K, V: Serial, S: HasStateApi> {
Vacant(VacantEntry<'a, K, V, S>),
Occupied(OccupiedEntry<'a, K, V, S>),
}
Expand description
Variants§
Vacant(VacantEntry<'a, K, V, S>)
Occupied(OccupiedEntry<'a, K, V, S>)
Implementations§
source§impl<'a, K, V, StateApi> Entry<'a, K, V, StateApi>
impl<'a, K, V, StateApi> Entry<'a, K, V, StateApi>
sourcepub fn is_occupied(&self) -> bool
pub fn is_occupied(&self) -> bool
Return whether the entry is occupied.
sourcepub fn occupied_or<E>(
self,
e: E
) -> Result<OccupiedEntry<'a, K, V, StateApi>, E>
pub fn occupied_or<E>( self, e: E ) -> Result<OccupiedEntry<'a, K, V, StateApi>, E>
If the entry is Occupied
return Ok
. Otherwise
return the supplied error.
sourcepub fn vacant_or<E>(self, e: E) -> Result<VacantEntry<'a, K, V, StateApi>, E>
pub fn vacant_or<E>(self, e: E) -> Result<VacantEntry<'a, K, V, StateApi>, E>
If the entry is Vacant
return Ok
. Otherwise return
the supplied error.
sourcepub fn or_insert(self, value: V) -> OccupiedEntry<'a, K, V, StateApi>
pub fn or_insert(self, value: V) -> OccupiedEntry<'a, K, V, StateApi>
Ensure a value is in the entry by inserting the provided value if the entry is vacant.
sourcepub fn or_insert_with<F>(self, default: F) -> OccupiedEntry<'a, K, V, StateApi>where
F: FnOnce() -> V,
pub fn or_insert_with<F>(self, default: F) -> OccupiedEntry<'a, K, V, StateApi>where
F: FnOnce() -> V,
Ensures a value is in the entry by inserting the result of the default function if empty.
sourcepub fn and_try_modify<F, E>(self, f: F) -> Result<Entry<'a, K, V, StateApi>, E>
pub fn and_try_modify<F, E>(self, f: F) -> Result<Entry<'a, K, V, StateApi>, E>
If the entry is occupied apply the given function to its contents. If the function returns an error the contents are not updated. If the supplied function returns an error then it should not modify the given value. If it does so than the map will become inconsistent. If the entry is vacant no changes are made.
sourcepub fn and_modify<F>(self, f: F) -> Entry<'a, K, V, StateApi>
pub fn and_modify<F>(self, f: F) -> Entry<'a, K, V, StateApi>
If the entry is occupied apply the given function to its contents. If the entry is vacant no changes are made.
source§impl<'a, K, V, StateApi> Entry<'a, K, V, StateApi>
impl<'a, K, V, StateApi> Entry<'a, K, V, StateApi>
sourcepub fn or_default(self) -> OccupiedEntry<'a, K, V, StateApi>
pub fn or_default(self) -> OccupiedEntry<'a, K, V, StateApi>
Ensures a value is in the entry by inserting the default value if empty.