armdb 0.12.0

sharded bitcask key-value storage optimized for NVMe
Documentation
use crate::codec::Codec;
use crate::error::DbResult;
use crate::held_ops::HeldOps;
use crate::key::Key;
use crate::lsm::LsmShard;
use crate::{CollectionMeta, TypedWriteHook};

impl<K, T, C, H> HeldOps for LsmShard<'_, K, T, C, H>
where
    K: Key + Ord,
    T: CollectionMeta<SelfId = K> + Send + Sync,
    C: Codec<T> + Clone,
    H: TypedWriteHook<K, T>,
{
    type Key = K;
    type Val = T;

    fn try_contains(&mut self, key: &K) -> DbResult<bool> {
        LsmShard::try_contains(self, key)
    }

    fn with_value<R>(&mut self, key: &K, f: impl FnOnce(&T) -> R) -> DbResult<Option<R>> {
        Ok(LsmShard::try_get(self, key)?.map(|value| f(&value)))
    }

    fn put(&mut self, key: &K, value: T) -> DbResult<()> {
        LsmShard::put(self, key, &value)
    }

    fn delete(&mut self, key: &K) -> DbResult<()> {
        LsmShard::delete(self, key).map(drop)
    }
}