-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use core::convert::Infallible; | ||
use revm::{Database, DatabaseCommit}; | ||
|
||
/// 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 | ||
pub trait DbConnect: Sync { | ||
/// The database type returned when connecting. | ||
type Database: Database + DatabaseCommit; | ||
|
||
/// The error type returned when connecting to the database. | ||
type Error: core::error::Error; | ||
|
||
/// Connect to the database. | ||
fn connect(&self) -> Result<Self::Database, Self::Error>; | ||
} | ||
|
||
impl<Db> DbConnect for Db | ||
where | ||
Db: Database + DatabaseCommit + Clone + Sync, | ||
{ | ||
type Database = Self; | ||
|
||
type Error = Infallible; | ||
|
||
fn connect(&self) -> Result<Self::Database, Self::Error> { | ||
Ok(self.clone()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters