From c103ca8bf2f7c8168f4224ae610aed7d82c19618 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 7 Jun 2022 17:56:11 +0200 Subject: Correct error type for (unimplemented) iterators in transactions --- src/db/lib.rs | 17 +++++++++-------- src/db/lmdb_adapter.rs | 10 +++++----- src/db/sled_adapter.rs | 10 +++++----- src/db/sqlite_adapter.rs | 10 +++++----- 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, usize); pub type Value = Vec; pub type ValueIter<'a> = Box> + 'a>; +pub type TxValueIter<'a> = Box> + 'a>; // ---- @@ -251,16 +252,16 @@ impl<'a> Transaction<'a> { } #[inline] - pub fn iter(&self, tree: &Tree) -> TxOpResult> { + pub fn iter(&self, tree: &Tree) -> TxOpResult> { self.0.iter(tree.1) } #[inline] - pub fn iter_rev(&self, tree: &Tree) -> TxOpResult> { + pub fn iter_rev(&self, tree: &Tree) -> TxOpResult> { self.0.iter_rev(tree.1) } #[inline] - pub fn range(&self, tree: &Tree, range: R) -> TxOpResult> + pub fn range(&self, tree: &Tree, range: R) -> TxOpResult> where K: AsRef<[u8]>, R: RangeBounds, @@ -270,7 +271,7 @@ impl<'a> Transaction<'a> { self.0.range(tree.1, get_bound(sb), get_bound(eb)) } #[inline] - pub fn range_rev(&self, tree: &Tree, range: R) -> TxOpResult> + pub fn range_rev(&self, tree: &Tree, range: R) -> TxOpResult> where K: AsRef<[u8]>, R: RangeBounds, @@ -331,21 +332,21 @@ pub(crate) trait ITx { fn insert(&mut self, tree: usize, key: &[u8], value: &[u8]) -> TxOpResult>; fn remove(&mut self, tree: usize, key: &[u8]) -> TxOpResult>; - fn iter(&self, tree: usize) -> TxOpResult>; - fn iter_rev(&self, tree: usize) -> TxOpResult>; + fn iter(&self, tree: usize) -> TxOpResult>; + fn iter_rev(&self, tree: usize) -> TxOpResult>; fn range<'r>( &self, tree: usize, low: Bound<&'r [u8]>, high: Bound<&'r [u8]>, - ) -> TxOpResult>; + ) -> TxOpResult>; fn range_rev<'r>( &self, tree: usize, low: Bound<&'r [u8]>, high: Bound<&'r [u8]>, - ) -> TxOpResult>; + ) -> TxOpResult>; } 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> { + fn iter(&self, _tree: usize) -> TxOpResult> { unimplemented!("Iterators in transactions not supported with LMDB backend"); } - fn iter_rev(&self, _tree: usize) -> TxOpResult> { + fn iter_rev(&self, _tree: usize) -> TxOpResult> { 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> { + ) -> TxOpResult> { 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> { + ) -> TxOpResult> { 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> { + fn iter(&self, _tree: usize) -> TxOpResult> { unimplemented!("Iterators in transactions not supported with Sled backend"); } - fn iter_rev(&self, _tree: usize) -> TxOpResult> { + fn iter_rev(&self, _tree: usize) -> TxOpResult> { 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> { + ) -> TxOpResult> { 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> { + ) -> TxOpResult> { 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> { + fn iter(&self, _tree: usize) -> TxOpResult> { unimplemented!(); } - fn iter_rev(&self, _tree: usize) -> TxOpResult> { + fn iter_rev(&self, _tree: usize) -> TxOpResult> { unimplemented!(); } @@ -384,7 +384,7 @@ impl<'a> ITx for SqliteTx<'a> { _tree: usize, _low: Bound<&'r [u8]>, _high: Bound<&'r [u8]>, - ) -> TxOpResult> { + ) -> TxOpResult> { 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> { + ) -> TxOpResult> { unimplemented!(); } } -- cgit v1.2.3