feat: database backend selection at runtime

This commit is contained in:
Timo Kösters 2022-01-09 16:44:44 +01:00
parent 4f39d36e98
commit fa6d7f7ccd
No known key found for this signature in database
GPG key ID: 356E705610F626D5
7 changed files with 116 additions and 88 deletions

View file

@ -18,10 +18,15 @@ pub mod rocksdb;
#[cfg(any(feature = "sqlite", feature = "rocksdb", feature = "heed"))]
pub mod watchers;
pub trait DatabaseEngine: Sized {
fn open(config: &Config) -> Result<Arc<Self>>;
fn open_tree(self: &Arc<Self>, name: &'static str) -> Result<Arc<dyn Tree>>;
fn flush(self: &Arc<Self>) -> Result<()>;
pub trait DatabaseEngine: Send + Sync {
fn open(config: &Config) -> Result<Self>
where
Self: Sized;
fn open_tree(&self, name: &'static str) -> Result<Arc<dyn Tree>>;
fn flush(self: &Self) -> Result<()>;
fn cleanup(self: &Self) -> Result<()> {
Ok(())
}
}
pub trait Tree: Send + Sync {