use crate::{ cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO, DbDupCursorRW}, table::{DupSort, Table}, DatabaseError, }; /// Read only transaction pub trait DbTx: Send + Sync { /// Cursor type for this read-only transaction type Cursor: DbCursorRO + Send + Sync; /// `DupCursor` type for this read-only transaction type DupCursor: DbDupCursorRO + DbCursorRO + Send + Sync; /// Get value fn get(&self, key: T::Key) -> Result, DatabaseError>; /// Commit for read only transaction will consume and free transaction and allows /// freeing of memory pages fn commit(self) -> Result; /// Aborts transaction fn abort(self); /// Iterate over read only values in table. fn cursor_read(&self) -> Result, DatabaseError>; /// Iterate over read only values in dup sorted table. fn cursor_dup_read(&self) -> Result, DatabaseError>; /// Returns number of entries in the table. fn entries(&self) -> Result; /// Disables long-lived read transaction safety guarantees. fn disable_long_read_transaction_safety(&mut self); } /// Read write transaction that allows writing to database pub trait DbTxMut: Send + Sync { /// Read-Write Cursor type type CursorMut: DbCursorRW + DbCursorRO + Send + Sync; /// Read-Write `DupCursor` type type DupCursorMut: DbDupCursorRW + DbCursorRW + DbDupCursorRO + DbCursorRO + Send + Sync; /// Put value to database fn put(&self, key: T::Key, value: T::Value) -> Result<(), DatabaseError>; /// Delete value from database fn delete(&self, key: T::Key, value: Option) -> Result; /// Clears database. fn clear(&self) -> Result<(), DatabaseError>; /// Cursor mut fn cursor_write(&self) -> Result, DatabaseError>; /// `DupCursor` mut. fn cursor_dup_write(&self) -> Result, DatabaseError>; }