Skip to main content

nimiq_database/traits/
database.rs

1use super::{DupTable, ReadTransaction, RegularTable, WriteTransaction};
2
3/// A database handle that can hold multiple tables.
4pub trait Database: Sized {
5    type ReadTransaction<'db>: ReadTransaction<'db>
6    where
7        Self: 'db;
8    type WriteTransaction<'db>: WriteTransaction<'db>
9    where
10        Self: 'db;
11
12    /// Creates a regular table (no-duplicates).
13    fn create_regular_table<T: RegularTable>(&self, table: &T);
14
15    /// Creates a table that can store duplicate keys.
16    fn create_dup_table<T: DupTable>(&self, table: &T);
17
18    /// Creates a read transaction.
19    fn read_transaction(&self) -> Self::ReadTransaction<'_>;
20
21    /// Creates a read/write transaction.
22    fn write_transaction(&self) -> Self::WriteTransaction<'_>;
23}