cuprate_database/backend/heed/transaction.rs
1//! Implementation of `trait TxRo/TxRw` for `heed`.
2
3use std::cell::RefCell;
4
5//---------------------------------------------------------------------------------------------------- Import
6use crate::{
7 error::DbResult,
8 transaction::{TxRo, TxRw},
9};
10
11//---------------------------------------------------------------------------------------------------- TxRo
12impl TxRo<'_> for heed::RoTxn<'_> {
13 fn commit(self) -> DbResult<()> {
14 Ok(heed::RoTxn::commit(self)?)
15 }
16}
17
18//---------------------------------------------------------------------------------------------------- TxRw
19impl TxRo<'_> for RefCell<heed::RwTxn<'_>> {
20 fn commit(self) -> DbResult<()> {
21 TxRw::commit(self)
22 }
23}
24
25impl TxRw<'_> for RefCell<heed::RwTxn<'_>> {
26 fn commit(self) -> DbResult<()> {
27 Ok(heed::RwTxn::commit(self.into_inner())?)
28 }
29
30 /// This function is infallible.
31 fn abort(self) -> DbResult<()> {
32 heed::RwTxn::abort(self.into_inner());
33 Ok(())
34 }
35}
36
37//---------------------------------------------------------------------------------------------------- Tests
38#[cfg(test)]
39mod test {
40 // use super::*;
41}