1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-06-27 16:35:59 +00:00

asyncify KeyValueDatabaseEngine

This commit is contained in:
chayleaf 2024-06-22 21:08:17 +07:00
parent 4b9520b5ad
commit a7e34eb0b3
No known key found for this signature in database
GPG key ID: 78171AD46227E68E
9 changed files with 121 additions and 111 deletions

View file

@ -1,6 +1,7 @@
use super::Config;
use crate::Result;
use async_trait::async_trait;
use std::{future::Future, pin::Pin, sync::Arc};
#[cfg(feature = "sled")]
@ -26,16 +27,17 @@ pub mod persy;
))]
pub mod watchers;
#[async_trait]
pub trait KeyValueDatabaseEngine: Send + Sync {
fn open(config: &Config) -> Result<Self>
async fn open(config: &Config) -> Result<Self>
where
Self: Sized;
fn open_tree(&self, name: &'static str) -> Result<Arc<dyn KvTree>>;
fn flush(&self) -> Result<()>;
fn cleanup(&self) -> Result<()> {
async fn open_tree(&self, name: &'static str) -> Result<Arc<dyn KvTree>>;
async fn flush(&self) -> Result<()>;
async fn cleanup(&self) -> Result<()> {
Ok(())
}
fn memory_usage(&self) -> Result<String> {
async fn memory_usage(&self) -> Result<String> {
Ok("Current database engine does not support memory usage reporting.".to_owned())
}
}