simple_database

Trait KeyValueStore

Source
pub trait KeyValueStore:
    Debug
    + Send
    + Sync
    + DynClone {
    // Required methods
    fn new(location: PathBuf) -> Result<Self, Error>
       where Self: Sized;
    fn partition(
        &mut self,
        path: PathBuf,
    ) -> Result<&mut dyn KeyValueStore, Error>;
    fn get_partition(&self, path: PathBuf) -> Option<&dyn KeyValueStore>;
    fn clear(&mut self) -> Result<(), Error>;
    fn delete(&mut self, key: &[u8]) -> Result<(), Error>;
    fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Error>;
    fn set(&mut self, key: &[u8], value: &[u8]) -> Result<(), Error>;
    fn get_all(&self) -> Result<KeyValue, Error>;
    fn keys(&self) -> Result<Vec<Vec<u8>>, Error>;
    fn values(&self) -> Result<Vec<Vec<u8>>, Error>;
    fn location(&self) -> PathBuf;
}

Required Methods§

Source

fn new(location: PathBuf) -> Result<Self, Error>
where Self: Sized,

Source

fn partition(&mut self, path: PathBuf) -> Result<&mut dyn KeyValueStore, Error>

Source

fn get_partition(&self, path: PathBuf) -> Option<&dyn KeyValueStore>

Source

fn clear(&mut self) -> Result<(), Error>

Source

fn delete(&mut self, key: &[u8]) -> Result<(), Error>

Source

fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Error>

Source

fn set(&mut self, key: &[u8], value: &[u8]) -> Result<(), Error>

Source

fn get_all(&self) -> Result<KeyValue, Error>

Source

fn keys(&self) -> Result<Vec<Vec<u8>>, Error>

Source

fn values(&self) -> Result<Vec<Vec<u8>>, Error>

Source

fn location(&self) -> PathBuf

Implementors§