use crate::errors::AtomicResult;
use super::trees::{Operation, Tree};
pub type KvPair = (Vec<u8>, Vec<u8>);
pub type KvIter = Box<dyn Iterator<Item = AtomicResult<KvPair>> + Send>;
pub trait KvStore: Send + Sync {
fn get(&self, tree: Tree, key: &[u8]) -> AtomicResult<Option<Vec<u8>>>;
fn insert(&self, tree: Tree, key: &[u8], val: &[u8]) -> AtomicResult<()>;
fn remove(&self, tree: Tree, key: &[u8]) -> AtomicResult<()>;
fn contains_key(&self, tree: Tree, key: &[u8]) -> AtomicResult<bool>;
fn scan_prefix(&self, tree: Tree, prefix: &[u8]) -> KvIter;
fn range(&self, tree: Tree, start: Vec<u8>, end: Vec<u8>, reverse: bool) -> KvIter;
fn iter_tree(&self, tree: Tree) -> KvIter;
fn clear_tree(&self, tree: Tree) -> AtomicResult<()>;
fn apply_batch(&self, operations: &[Operation]) -> AtomicResult<()>;
fn flush(&self) -> AtomicResult<()>;
fn begin_batch(&self) {}
fn commit_batch(&self) -> AtomicResult<()> {
Ok(())
}
fn len(&self, tree: Tree) -> AtomicResult<usize>;
}