use std::sync::Arc; use rocksdb::{ThreadMode, Transaction, TransactionDB}; use crate::*; impl Get for Transaction<'_, TransactionDB> { fn get(&self, key: impl AsRef<[u8]>) -> Option> { self.get(key).expect("couldn't read from RocksDB via transaction") } } impl DbTxn for Transaction<'_, TransactionDB> { fn put(&mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>) { Transaction::put(self, key, value).expect("couldn't write to RocksDB via transaction") } fn del(&mut self, key: impl AsRef<[u8]>) { self.delete(key).expect("couldn't delete from RocksDB via transaction") } fn commit(self) { Transaction::commit(self).expect("couldn't commit to RocksDB via transaction") } } impl Get for Arc> { fn get(&self, key: impl AsRef<[u8]>) -> Option> { TransactionDB::get(self, key).expect("couldn't read from RocksDB") } } impl Db for Arc> { type Transaction<'a> = Transaction<'a, TransactionDB>; fn txn(&mut self) -> Self::Transaction<'_> { self.transaction() } }