Database in reth_db_api::database - Rust

pub trait Database:
    Send
    + Sync
    + Debug {
    type TX: DbTx + Send + Sync + Debug + 'static;
    type TXMut: DbTxMut + DbTx + TableImporter + Send + Sync + Debug + 'static;

    // Required methods
    fn tx(&self) -> Result<Self::TX, DatabaseError>;
    fn tx_mut(&self) -> Result<Self::TXMut, DatabaseError>;
    fn path(&self) -> PathBuf;

    // Provided methods
    fn view<T, F>(&self, f: F) -> Result<T, DatabaseError>
       where F: FnOnce(&mut Self::TX) -> T { ... }
    fn update<T, F>(&self, f: F) -> Result<T, DatabaseError>
       where F: FnOnce(&Self::TXMut) -> T { ... }
}
Expand description

Main Database trait that can open read-only and read-write transactions.

Sealed trait which cannot be implemented by 3rd parties, exposed only for consumption.

Source

Read-Only database transaction

Source

Read-Write database transaction

Source

Create read only transaction.

Source

Create read write transaction only possible if database is open with write access.

Source

Returns the path to the database directory.

Source

Takes a function and passes a read-only transaction into it, making sure it’s closed in the end of the execution.

Source

Takes a function and passes a write-read transaction into it, making sure it’s committed in the end of the execution.

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Source§

Source§
Source§
Source§
Source§
Source§

Source§

Source§
Source§
Source§
Source§
Source§