pub struct VarTypedShard<'tree, K: Key, T: Send + Sync, C: Codec<T> + Clone, H: TypedWriteHook<K, T>> { /* private fields */ }Expand description
Handle for atomic multi-key operations within a single shard.
Obtained via VarTypedTree::atomic. The shard lock is held for the
lifetime of this struct — keep the closure short.
Implementations§
Source§impl<K: Key, T: Send + Sync, C: Codec<T> + Clone, H: TypedWriteHook<K, T>> VarTypedShard<'_, K, T, C, H>
impl<K: Key, T: Send + Sync, C: Codec<T> + Clone, H: TypedWriteHook<K, T>> VarTypedShard<'_, 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, T: Send + Sync, C: Codec<T> + Clone, H: TypedWriteHook<K, T>> Send for VarTypedShard<'_, K, T, C, H>
Auto Trait Implementations§
impl<'tree, K, T, C, H> !RefUnwindSafe for VarTypedShard<'tree, K, T, C, H>
impl<'tree, K, T, C, H> !Sync for VarTypedShard<'tree, K, T, C, H>
impl<'tree, K, T, C, H> !UnwindSafe for VarTypedShard<'tree, K, T, C, H>
impl<'tree, K, T, C, H> Freeze for VarTypedShard<'tree, K, T, C, H>where
&'tree VarTypedTree<K, T, C, H>: Freeze,
impl<'tree, K, T, C, H> Unpin for VarTypedShard<'tree, K, T, C, H>where
&'tree VarTypedTree<K, T, C, H>: Unpin,
impl<'tree, K, T, C, H> UnsafeUnpin for VarTypedShard<'tree, K, T, C, H>where
&'tree VarTypedTree<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