optimize get w/ zero-copy ref handle

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-02 05:56:10 +00:00
parent 0522fe7d92
commit ee64fb149c
11 changed files with 46 additions and 16 deletions

25
src/database/handle.rs Normal file
View file

@ -0,0 +1,25 @@
use std::ops::Deref;
use rocksdb::DBPinnableSlice;
pub struct Handle<'a> {
val: DBPinnableSlice<'a>,
}
impl<'a> From<DBPinnableSlice<'a>> for Handle<'a> {
fn from(val: DBPinnableSlice<'a>) -> Self {
Self {
val,
}
}
}
impl Deref for Handle<'_> {
type Target = [u8];
fn deref(&self) -> &Self::Target { &self.val }
}
impl AsRef<[u8]> for Handle<'_> {
fn as_ref(&self) -> &[u8] { &self.val }
}