aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/db/lib.rs17
-rw-r--r--src/db/lmdb_adapter.rs10
-rw-r--r--src/db/sled_adapter.rs10
-rw-r--r--src/db/sqlite_adapter.rs10
4 files changed, 24 insertions, 23 deletions
diff --git a/src/db/lib.rs b/src/db/lib.rs
index a4da4086..d4b5c519 100644
--- a/src/db/lib.rs
+++ b/src/db/lib.rs
@@ -25,6 +25,7 @@ pub struct Tree(Arc<dyn IDb>, usize);
pub type Value = Vec<u8>;
pub type ValueIter<'a> = Box<dyn std::iter::Iterator<Item = Result<(Value, Value)>> + 'a>;
+pub type TxValueIter<'a> = Box<dyn std::iter::Iterator<Item = TxOpResult<(Value, Value)>> + 'a>;
// ----
@@ -251,16 +252,16 @@ impl<'a> Transaction<'a> {
}
#[inline]
- pub fn iter(&self, tree: &Tree) -> TxOpResult<ValueIter<'_>> {
+ pub fn iter(&self, tree: &Tree) -> TxOpResult<TxValueIter<'_>> {
self.0.iter(tree.1)
}
#[inline]
- pub fn iter_rev(&self, tree: &Tree) -> TxOpResult<ValueIter<'_>> {
+ pub fn iter_rev(&self, tree: &Tree) -> TxOpResult<TxValueIter<'_>> {
self.0.iter_rev(tree.1)
}
#[inline]
- pub fn range<K, R>(&self, tree: &Tree, range: R) -> TxOpResult<ValueIter<'_>>
+ pub fn range<K, R>(&self, tree: &Tree, range: R) -> TxOpResult<TxValueIter<'_>>
where
K: AsRef<[u8]>,
R: RangeBounds<K>,
@@ -270,7 +271,7 @@ impl<'a> Transaction<'a> {
self.0.range(tree.1, get_bound(sb), get_bound(eb))
}
#[inline]
- pub fn range_rev<K, R>(&self, tree: &Tree, range: R) -> TxOpResult<ValueIter<'_>>
+ pub fn range_rev<K, R>(&self, tree: &Tree, range: R) -> TxOpResult<TxValueIter<'_>>
where
K: AsRef<[u8]>,
R: RangeBounds<K>,
@@ -331,21 +332,21 @@ pub(crate) trait ITx {
fn insert(&mut self, tree: usize, key: &[u8], value: &[u8]) -> TxOpResult<Option<Value>>;
fn remove(&mut self, tree: usize, key: &[u8]) -> TxOpResult<Option<Value>>;
- fn iter(&self, tree: usize) -> TxOpResult<ValueIter<'_>>;
- fn iter_rev(&self, tree: usize) -> TxOpResult<ValueIter<'_>>;
+ fn iter(&self, tree: usize) -> TxOpResult<TxValueIter<'_>>;
+ fn iter_rev(&self, tree: usize) -> TxOpResult<TxValueIter<'_>>;
fn range<'r>(
&self,
tree: usize,
low: Bound<&'r [u8]>,
high: Bound<&'r [u8]>,
- ) -> TxOpResult<ValueIter<'_>>;
+ ) -> TxOpResult<TxValueIter<'_>>;
fn range_rev<'r>(
&self,
tree: usize,
low: Bound<&'r [u8]>,
high: Bound<&'r [u8]>,
- ) -> TxOpResult<ValueIter<'_>>;
+ ) -> TxOpResult<TxValueIter<'_>>;
}
pub(crate) trait ITxFn {
diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs
index d1efd216..50885dad 100644
--- a/src/db/lmdb_adapter.rs
+++ b/src/db/lmdb_adapter.rs
@@ -10,7 +10,7 @@ use heed::{BytesDecode, Env, RoTxn, RwTxn, UntypedDatabase as Database};
use crate::{
Db, Error, IDb, ITx, ITxFn, Result, TxError, TxFnResult, TxOpError, TxOpResult, TxResult,
- Value, ValueIter,
+ Value, ValueIter, TxValueIter
};
pub use heed;
@@ -243,10 +243,10 @@ impl<'a, 'db> ITx for LmdbTx<'a, 'db> {
Ok(old_val)
}
- fn iter(&self, _tree: usize) -> TxOpResult<ValueIter<'_>> {
+ fn iter(&self, _tree: usize) -> TxOpResult<TxValueIter<'_>> {
unimplemented!("Iterators in transactions not supported with LMDB backend");
}
- fn iter_rev(&self, _tree: usize) -> TxOpResult<ValueIter<'_>> {
+ fn iter_rev(&self, _tree: usize) -> TxOpResult<TxValueIter<'_>> {
unimplemented!("Iterators in transactions not supported with LMDB backend");
}
@@ -255,7 +255,7 @@ impl<'a, 'db> ITx for LmdbTx<'a, 'db> {
_tree: usize,
_low: Bound<&'r [u8]>,
_high: Bound<&'r [u8]>,
- ) -> TxOpResult<ValueIter<'_>> {
+ ) -> TxOpResult<TxValueIter<'_>> {
unimplemented!("Iterators in transactions not supported with LMDB backend");
}
fn range_rev<'r>(
@@ -263,7 +263,7 @@ impl<'a, 'db> ITx for LmdbTx<'a, 'db> {
_tree: usize,
_low: Bound<&'r [u8]>,
_high: Bound<&'r [u8]>,
- ) -> TxOpResult<ValueIter<'_>> {
+ ) -> TxOpResult<TxValueIter<'_>> {
unimplemented!("Iterators in transactions not supported with LMDB backend");
}
}
diff --git a/src/db/sled_adapter.rs b/src/db/sled_adapter.rs
index d0d9e9c0..bcda32a6 100644
--- a/src/db/sled_adapter.rs
+++ b/src/db/sled_adapter.rs
@@ -11,7 +11,7 @@ use sled::transaction::{
use crate::{
Db, Error, IDb, ITx, ITxFn, Result, TxError, TxFnResult, TxOpError, TxOpResult, TxResult,
- Value, ValueIter,
+ Value, ValueIter, TxValueIter
};
pub use sled;
@@ -230,10 +230,10 @@ impl<'a> ITx for SledTx<'a> {
Ok(old_val.map(|x| x.to_vec()))
}
- fn iter(&self, _tree: usize) -> TxOpResult<ValueIter<'_>> {
+ fn iter(&self, _tree: usize) -> TxOpResult<TxValueIter<'_>> {
unimplemented!("Iterators in transactions not supported with Sled backend");
}
- fn iter_rev(&self, _tree: usize) -> TxOpResult<ValueIter<'_>> {
+ fn iter_rev(&self, _tree: usize) -> TxOpResult<TxValueIter<'_>> {
unimplemented!("Iterators in transactions not supported with Sled backend");
}
@@ -242,7 +242,7 @@ impl<'a> ITx for SledTx<'a> {
_tree: usize,
_low: Bound<&'r [u8]>,
_high: Bound<&'r [u8]>,
- ) -> TxOpResult<ValueIter<'_>> {
+ ) -> TxOpResult<TxValueIter<'_>> {
unimplemented!("Iterators in transactions not supported with Sled backend");
}
fn range_rev<'r>(
@@ -250,7 +250,7 @@ impl<'a> ITx for SledTx<'a> {
_tree: usize,
_low: Bound<&'r [u8]>,
_high: Bound<&'r [u8]>,
- ) -> TxOpResult<ValueIter<'_>> {
+ ) -> TxOpResult<TxValueIter<'_>> {
unimplemented!("Iterators in transactions not supported with Sled backend");
}
}
diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs
index 8d6bd714..402ff7a4 100644
--- a/src/db/sqlite_adapter.rs
+++ b/src/db/sqlite_adapter.rs
@@ -12,7 +12,7 @@ use rusqlite::{params, Connection, Rows, Statement, Transaction};
use crate::{
Db, Error, IDb, ITx, ITxFn, Result, TxError, TxFnResult, TxOpError, TxOpResult, TxResult,
- Value, ValueIter,
+ Value, ValueIter, TxValueIter
};
pub use rusqlite;
@@ -372,10 +372,10 @@ impl<'a> ITx for SqliteTx<'a> {
Ok(old_val)
}
- fn iter(&self, _tree: usize) -> TxOpResult<ValueIter<'_>> {
+ fn iter(&self, _tree: usize) -> TxOpResult<TxValueIter<'_>> {
unimplemented!();
}
- fn iter_rev(&self, _tree: usize) -> TxOpResult<ValueIter<'_>> {
+ fn iter_rev(&self, _tree: usize) -> TxOpResult<TxValueIter<'_>> {
unimplemented!();
}
@@ -384,7 +384,7 @@ impl<'a> ITx for SqliteTx<'a> {
_tree: usize,
_low: Bound<&'r [u8]>,
_high: Bound<&'r [u8]>,
- ) -> TxOpResult<ValueIter<'_>> {
+ ) -> TxOpResult<TxValueIter<'_>> {
unimplemented!();
}
fn range_rev<'r>(
@@ -392,7 +392,7 @@ impl<'a> ITx for SqliteTx<'a> {
_tree: usize,
_low: Bound<&'r [u8]>,
_high: Bound<&'r [u8]>,
- ) -> TxOpResult<ValueIter<'_>> {
+ ) -> TxOpResult<TxValueIter<'_>> {
unimplemented!();
}
}