fix: changes to update to the last database engine trait definition
This commit is contained in:
parent
1cc41937bd
commit
f9977ca64f
2 changed files with 12 additions and 7 deletions
|
@ -18,7 +18,12 @@ pub mod rocksdb;
|
|||
#[cfg(feature = "persy")]
|
||||
pub mod persy;
|
||||
|
||||
#[cfg(any(feature = "sqlite", feature = "rocksdb", feature = "heed", feature="persy"))]
|
||||
#[cfg(any(
|
||||
feature = "sqlite",
|
||||
feature = "rocksdb",
|
||||
feature = "heed",
|
||||
feature = "persy"
|
||||
))]
|
||||
pub mod watchers;
|
||||
|
||||
pub trait DatabaseEngine: Send + Sync {
|
||||
|
|
|
@ -11,12 +11,12 @@ use std::{future::Future, pin::Pin, sync::Arc};
|
|||
|
||||
use tracing::warn;
|
||||
|
||||
pub struct PersyEngine {
|
||||
pub struct Engine {
|
||||
persy: Persy,
|
||||
}
|
||||
|
||||
impl DatabaseEngine for PersyEngine {
|
||||
fn open(config: &Config) -> Result<Arc<Self>> {
|
||||
impl DatabaseEngine for Arc<Engine> {
|
||||
fn open(config: &Config) -> Result<Self> {
|
||||
let mut cfg = persy::Config::new();
|
||||
cfg.change_cache_size((config.db_cache_capacity_mb * 1024.0 * 1024.0) as u64);
|
||||
|
||||
|
@ -24,10 +24,10 @@ impl DatabaseEngine for PersyEngine {
|
|||
.create(true)
|
||||
.config(cfg)
|
||||
.open(&format!("{}/db.persy", config.database_path))?;
|
||||
Ok(Arc::new(PersyEngine { persy }))
|
||||
Ok(Arc::new(Engine { persy }))
|
||||
}
|
||||
|
||||
fn open_tree(self: &Arc<Self>, name: &'static str) -> Result<Arc<dyn Tree>> {
|
||||
fn open_tree(&self, name: &'static str) -> Result<Arc<dyn Tree>> {
|
||||
// Create if it doesn't exist
|
||||
if !self.persy.exists_index(name)? {
|
||||
let mut tx = self.persy.begin()?;
|
||||
|
@ -42,7 +42,7 @@ impl DatabaseEngine for PersyEngine {
|
|||
}))
|
||||
}
|
||||
|
||||
fn flush(self: &Arc<Self>) -> Result<()> {
|
||||
fn flush(&self) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue