simplify & fix db tests
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Alex 2022-06-07 18:06:30 +02:00
parent daec7995c3
commit d41a67c4ee
Signed by: lx
GPG key ID: 0E496D15096376BE
2 changed files with 6 additions and 5 deletions

View file

@ -35,10 +35,11 @@ pub struct Error(pub Cow<'static, str>);
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
#[error(display = "{}", _0)]
pub struct TxOpError(pub(crate) Error);
pub type TxOpResult<T> = std::result::Result<T, TxOpError>;
#[derive(Debug)]
pub enum TxError<E> {
Abort(E),
Db(Error),

View file

@ -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<Option<Value>> {
let tree = self.get_tree(tree)?;
match tree.get(&self.tx, key)? {