Skip to main content

DbConnect

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

DbConnect is blanket implemented for clonable Database types by simply cloning the database instance. This allows already-instantiated DBs to be used as connectors, however, if the Database uses a shared resource like a file or network connection, care should be taken to ensure that the implementation does not share uintended state between EVM instances.

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,