From d41a67c4eea3dbb1e40e5eb0fcee28dd916c8f29 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 7 Jun 2022 18:06:30 +0200 Subject: simplify & fix db tests --- src/db/lib.rs | 3 ++- src/db/lmdb_adapter.rs | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/db/lib.rs b/src/db/lib.rs index d4b5c519..9fae7cc9 100644 --- a/src/db/lib.rs +++ b/src/db/lib.rs @@ -35,10 +35,11 @@ pub struct Error(pub Cow<'static, str>); pub type Result = std::result::Result; +#[derive(Debug, Error)] +#[error(display = "{}", _0)] pub struct TxOpError(pub(crate) Error); pub type TxOpResult = std::result::Result; -#[derive(Debug)] pub enum TxError { Abort(E), Db(Error), diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs index b82add75..23b8c87e 100644 --- a/src/db/lmdb_adapter.rs +++ b/src/db/lmdb_adapter.rs @@ -203,12 +203,12 @@ impl IDb for LmdbDb { // ---- -struct LmdbTx<'a, 'db> { - trees: &'db [Database], +struct LmdbTx<'a> { + trees: &'a [Database], tx: RwTxn<'a, 'a>, } -impl<'a, 'db> LmdbTx<'a, 'db> { +impl<'a> LmdbTx<'a> { fn get_tree(&self, i: usize) -> TxOpResult<&Database> { self.trees.get(i).ok_or_else(|| { TxOpError(Error( @@ -218,7 +218,7 @@ impl<'a, 'db> LmdbTx<'a, 'db> { } } -impl<'a, 'db> ITx for LmdbTx<'a, 'db> { +impl<'a> ITx for LmdbTx<'a> { fn get(&self, tree: usize, key: &[u8]) -> TxOpResult> { let tree = self.get_tree(tree)?; match tree.get(&self.tx, key)? { -- cgit v1.2.3