pub struct VarTypedMapShard<'tree, K: Key + Send + Sync + Hash + Eq, T: Send + Sync, C: Codec<T> + Clone, H: TypedWriteHook<K, T>> { /* private fields */ }Expand description
Handle for atomic multi-key operations on a single shard of a VarTypedMap.
Obtained via VarTypedMap::atomic. The shard + index locks are held for the
lifetime of this struct — keep the closure short.
Implementations§
Source§impl<K: Key + Send + Sync + Hash + Eq, T: Send + Sync, C: Codec<T> + Clone, H: TypedWriteHook<K, T>> VarTypedMapShard<'_, K, T, C, H>
impl<K: Key + Send + Sync + Hash + Eq, T: Send + Sync, C: Codec<T> + Clone, H: TypedWriteHook<K, T>> VarTypedMapShard<'_, K, T, C, H>
Sourcepub fn put(&mut self, key: &K, value: &T) -> DbResult<bool>
pub fn put(&mut self, key: &K, value: &T) -> DbResult<bool>
Insert or overwrite key. Returns true if the key already existed (overwrite),
false for a fresh insert.
pub fn insert(&mut self, key: &K, value: &T) -> DbResult<()>
pub fn delete(&mut self, key: &K) -> DbResult<bool>
pub fn try_get(&self, key: &K) -> DbResult<Option<T>>
pub fn get_or_err(&self, key: &K) -> DbResult<T>
pub fn try_contains(&self, key: &K) -> DbResult<bool>
Sourcepub fn update(
&mut self,
key: &K,
f: impl FnOnce(&T) -> T,
) -> DbResult<Option<T>>
pub fn update( &mut self, key: &K, f: impl FnOnce(&T) -> T, ) -> DbResult<Option<T>>
Atomically read-modify-write within the shard. Returns Some(new_value)
if the key existed, None if absent.
Trait Implementations§
impl<K: Key + Send + Sync + Hash + Eq, T: Send + Sync, C: Codec<T> + Clone, H: TypedWriteHook<K, T>> Send for VarTypedMapShard<'_, K, T, C, H>
Auto Trait Implementations§
impl<'tree, K, T, C, H> !RefUnwindSafe for VarTypedMapShard<'tree, K, T, C, H>
impl<'tree, K, T, C, H> !Sync for VarTypedMapShard<'tree, K, T, C, H>
impl<'tree, K, T, C, H> !UnwindSafe for VarTypedMapShard<'tree, K, T, C, H>
impl<'tree, K, T, C, H> Freeze for VarTypedMapShard<'tree, K, T, C, H>where
&'tree VarTypedMap<K, T, C, H>: Freeze,
impl<'tree, K, T, C, H> Unpin for VarTypedMapShard<'tree, K, T, C, H>where
&'tree VarTypedMap<K, T, C, H>: Unpin,
impl<'tree, K, T, C, H> UnsafeUnpin for VarTypedMapShard<'tree, K, T, C, H>where
&'tree VarTypedMap<K, T, C, H>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more