Trait DbConnect

Source
pub trait DbConnect: Sync {
    type Database: Database;
    type Error: Error;

    // Required method
    fn connect(&self) -> Result<Self::Database, Self::Error>;
}
Expand description

Trait for types that can be used to connect to a database.

Connectors should contain configuration information like filesystem paths. They are intended to enable parallel instantiation of multiple EVMs in multiple threads sharing some database configuration

The lifetime on this trait allows the resulting DB to borrow from the connector. E.g. the connector may contain some Db and the resulting Db may contain &Db. This allows for (e.g.) shared caches between DBs on multiple threads.

Required Associated Types§

Source

type Database: Database

The database type returned when connecting.

Source

type Error: Error

The error type returned when connecting to the database.

Required Methods§

Source

fn connect(&self) -> Result<Self::Database, Self::Error>

Connect to the database.

Implementors§

Source§

impl<Db> DbConnect for Db
where Db: Database + Clone + Sync,