in get_key_value pass value by ref

main
Niko 2 years ago
parent 843291a848
commit 19fc8e0b68
  1. 4
      src/backend/impl_lmdb/cursor.rs
  2. 6
      src/backend/impl_safe/cursor.rs
  3. 2
      src/backend/traits.rs
  4. 2
      src/store/multi.rs
  5. 6
      tests/env-lmdb.rs

@ -19,7 +19,7 @@ pub struct RoCursorImpl<'c>(pub(crate) lmdb::RoCursor<'c>);
impl<'c> BackendRoCursor<'c> for RoCursorImpl<'c> {
type Iter = IterImpl<'c, lmdb::RoCursor<'c>>;
fn get_key_value<K>(self, key: K, value: crate::value::Value) -> bool
fn get_key_value<K>(self, key: K, value: &crate::value::Value) -> bool
where
K: AsRef<[u8]> + 'c,
{
@ -68,7 +68,7 @@ pub struct RwCursorImpl<'c>(pub(crate) lmdb::RoCursor<'c>);
impl<'c> BackendRoCursor<'c> for RwCursorImpl<'c> {
type Iter = IterImpl<'c, lmdb::RoCursor<'c>>;
fn get_key_value<K>(self, key: K, value: crate::value::Value) -> bool
fn get_key_value<K>(self, key: K, value: &crate::value::Value) -> bool
where
K: AsRef<[u8]> + 'c,
{

@ -18,7 +18,7 @@ pub struct RoCursorImpl<'c>(pub(crate) &'c Snapshot);
impl<'c> BackendRoCursor<'c> for RoCursorImpl<'c> {
type Iter = IterImpl<'c>;
fn get_key_value<K>(self, key: K, value: crate::value::Value) -> bool {
fn get_key_value<K>(self, key: K, value: &crate::value::Value) -> bool {
unimplemented!();
}
@ -53,7 +53,7 @@ impl<'c> BackendRoCursor<'c> for RoCursorImpl<'c> {
impl<'c> BackendRoCursor<'c> for RoCursorImpl<'c> {
type Iter = IterImpl<'c>;
fn get_key_value<K>(self, key: K, value: crate::value::Value) -> bool
fn get_key_value<K>(self, key: K, value: &crate::value::Value) -> bool
where
K: AsRef<[u8]> + 'c,
{
@ -97,7 +97,7 @@ pub struct RwCursorImpl<'c>(&'c mut Snapshot);
impl<'c> BackendRoCursor<'c> for RwCursorImpl<'c> {
type Iter = IterImpl<'c>;
fn get_key_value<K>(self, key: K, value: crate::value::Value) -> bool
fn get_key_value<K>(self, key: K, value: &crate::value::Value) -> bool
where
K: AsRef<[u8]> + 'c,
{

@ -212,7 +212,7 @@ pub trait BackendRwDupPrevCursorTransaction: BackendRwTransaction {
pub trait BackendRoCursor<'c>: Debug {
type Iter: BackendIter<'c>;
fn get_key_value<K>(self, key: K, value: crate::value::Value) -> bool
fn get_key_value<K>(self, key: K, value: &crate::value::Value) -> bool
where
K: AsRef<[u8]> + 'c;

@ -91,7 +91,7 @@ where
&self,
reader: &'r R,
k: K,
v: Value,
v: &Value,
) -> Result<bool, StoreError>
where
R: Readable<'r, Database = D, RoCursor = C>,

@ -1201,17 +1201,17 @@ fn test_multi_get_key_value() {
let reader = k.read().unwrap();
let yes = sk
.get_key_value(&reader, "foo", Value::Blob(b"1234"))
.get_key_value(&reader, "foo", &Value::Blob(b"1234"))
.unwrap();
assert!(yes);
let yes = sk
.get_key_value(&reader, "foo", Value::Blob(b"12345"))
.get_key_value(&reader, "foo", &Value::Blob(b"12345"))
.unwrap();
assert!(!yes);
let yes = sk
.get_key_value(&reader, "foo2", Value::Blob(b"1234"))
.get_key_value(&reader, "foo2", &Value::Blob(b"1234"))
.unwrap();
assert!(!yes);
}

Loading…
Cancel
Save