1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-07-02 16:38:36 +00:00

KvTree: asyncify clear and increment

This commit is contained in:
chayleaf 2024-06-22 21:22:43 +07:00
parent a8c9e3eebe
commit 7658414fc4
No known key found for this signature in database
GPG key ID: 78171AD46227E68E
62 changed files with 958 additions and 650 deletions

View file

@ -42,6 +42,7 @@ pub trait KeyValueDatabaseEngine: Send + Sync {
}
}
#[async_trait]
pub trait KvTree: Send + Sync {
fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>>;
@ -58,7 +59,7 @@ pub trait KvTree: Send + Sync {
backwards: bool,
) -> Box<dyn Send + Iterator<Item = (Vec<u8>, Vec<u8>)> + 'a>;
fn increment(&self, key: &[u8]) -> Result<Vec<u8>>;
async fn increment(&self, key: &[u8]) -> Result<Vec<u8>>;
fn increment_batch(&self, iter: &mut dyn Iterator<Item = Vec<u8>>) -> Result<()>;
fn scan_prefix<'a>(
@ -68,7 +69,7 @@ pub trait KvTree: Send + Sync {
fn watch_prefix<'a>(&'a self, prefix: &[u8]) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>;
fn clear(&self) -> Result<()> {
async fn clear(&self) -> Result<()> {
for (key, _) in self.iter() {
self.remove(&key)?;
}