Database

Trait Database 

Source
pub trait Database: Send + Sync {
    // Required methods
    fn get(
        &self,
        category: Option<DataCategory>,
        key: &[u8],
    ) -> Result<Option<Vec<u8>>>;
    fn get_batch(
        &self,
        category: Option<DataCategory>,
        keys: &[Vec<u8>],
    ) -> Result<Vec<Option<Vec<u8>>>>;
    fn insert(
        &self,
        category: Option<DataCategory>,
        key: Vec<u8>,
        value: Vec<u8>,
    ) -> Result<()>;
    fn insert_batch(
        &self,
        category: Option<DataCategory>,
        keys: Vec<Vec<u8>>,
        values: Vec<Vec<u8>>,
    ) -> Result<()>;
    fn contains(
        &self,
        category: Option<DataCategory>,
        key: &[u8],
    ) -> Result<bool>;
    fn remove(&self, category: Option<DataCategory>, key: &[u8]) -> Result<()>;
    fn remove_batch(
        &self,
        category: Option<DataCategory>,
        keys: &[Vec<u8>],
    ) -> Result<()>;
    fn restore(&mut self, new_db: &str) -> Result<()>;
    fn iterator(&self, category: Option<DataCategory>) -> Option<DBIterator<'_>>;
    fn close(&mut self);
    fn flush(&self) -> Result<()>;
}

Required Methods§

Source

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

Source

fn get_batch( &self, category: Option<DataCategory>, keys: &[Vec<u8>], ) -> Result<Vec<Option<Vec<u8>>>>

Source

fn insert( &self, category: Option<DataCategory>, key: Vec<u8>, value: Vec<u8>, ) -> Result<()>

Source

fn insert_batch( &self, category: Option<DataCategory>, keys: Vec<Vec<u8>>, values: Vec<Vec<u8>>, ) -> Result<()>

Source

fn contains(&self, category: Option<DataCategory>, key: &[u8]) -> Result<bool>

Source

fn remove(&self, category: Option<DataCategory>, key: &[u8]) -> Result<()>

Source

fn remove_batch( &self, category: Option<DataCategory>, keys: &[Vec<u8>], ) -> Result<()>

Source

fn restore(&mut self, new_db: &str) -> Result<()>

Source

fn iterator(&self, category: Option<DataCategory>) -> Option<DBIterator<'_>>

Source

fn close(&mut self)

Source

fn flush(&self) -> Result<()>

Implementors§