Struct concread::hashtrie::asynch::HashTrieWriteTxn
source · pub struct HashTrieWriteTxn<'a, K, V>{ /* private fields */ }
Expand description
An active write transaction for a HashTrie
. The data in this tree
may be modified exclusively through this transaction without affecting
readers. The write may be rolledback/aborted by dropping this guard
without calling commit()
. Once commit()
is called, readers will be
able to access and perceive changes in new transactions.
Implementations§
source§impl<K: Hash + Eq + Clone + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> HashTrieWriteTxn<'_, K, V>
impl<K: Hash + Eq + Clone + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> HashTrieWriteTxn<'_, K, V>
sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
pub fn get<Q>(&self, k: &Q) -> Option<&V>
Retrieve a value from the map. If the value exists, a reference is returned
as Some(&V)
, otherwise if not present None
is returned.
sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
pub fn contains_key<Q>(&self, k: &Q) -> bool
Assert if a key exists in the map.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Reset this map to an empty state. As this is within the transaction this change only takes effect once committed. Once cleared, you can begin adding new writes and changes, again, that will only be visible once committed.
sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
pub fn insert(&mut self, k: K, v: V) -> Option<V>
Insert or update a value by key. If the value previously existed it is returned
as Some(V)
. If the value did not previously exist this returns None
.
sourcepub fn remove(&mut self, k: &K) -> Option<V>
pub fn remove(&mut self, k: &K) -> Option<V>
Remove a key if it exists in the tree. If the value exists, we return it as Some(V)
,
and if it did not exist, we return None
sourcepub fn get_mut(&mut self, k: &K) -> Option<&mut V>
pub fn get_mut(&mut self, k: &K) -> Option<&mut V>
Get a mutable reference to a value in the tree. This is correctly, and safely cloned before you attempt to mutate the value, isolating it from other transactions.
sourcepub fn to_snapshot(&self) -> HashTrieReadSnapshot<'_, K, V>
pub fn to_snapshot(&self) -> HashTrieReadSnapshot<'_, K, V>
Create a read-snapshot of the current map. This does NOT guarantee the map may not be mutated during the read, so you MUST guarantee that no functions of the write txn are called while this snapshot is active.
Trait Implementations§
source§impl<K: Hash + Eq + Clone + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> Extend<(K, V)> for HashTrieWriteTxn<'_, K, V>
impl<K: Hash + Eq + Clone + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> Extend<(K, V)> for HashTrieWriteTxn<'_, K, V>
source§fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)