optimize get w/ zero-copy ref handle
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
0522fe7d92
commit
ee64fb149c
11 changed files with 46 additions and 16 deletions
25
src/database/handle.rs
Normal file
25
src/database/handle.rs
Normal 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 }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue