web5_rust::common::traits

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<Vec<(Vec<u8>, Vec<u8>)>, 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<Vec<(Vec<u8>, Vec<u8>)>, 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§