1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
use bronzedb_util::status::Error;
use bronzedb_util::types::{Entry, Key, Value};

pub trait Engine {
    type Error: Into<Error>;
    fn set(&mut self, key: Key, value: Value) -> Result<(), Self::Error>;
    fn get(&self, key: Key) -> Result<Option<Value>, Self::Error>;
    fn delete(&mut self, key: Key) -> Result<(), Self::Error>;
    fn scan(
        &self,
        lower_bound: Option<Key>,
        upper_bound: Option<Key>,
    ) -> Result<Box<dyn Scanner + '_>, Self::Error>;
}

pub trait Scanner {
    fn iter(&mut self) -> Box<dyn Iterator<Item = Result<Entry, Error>> + '_>;
}