use std::borrow::Cow; use obkv::{KvReader, KvWriter}; pub struct ObkvCodec; impl<'a> heed::BytesDecode<'a> for ObkvCodec { type DItem = KvReader<'a>; fn bytes_decode(bytes: &'a [u8]) -> Option { Some(KvReader::new(bytes)) } } impl heed::BytesEncode<'_> for ObkvCodec { type EItem = KvWriter>; fn bytes_encode(item: &Self::EItem) -> Option> { item.clone().into_inner().map(Cow::Owned).ok() } }