Trait cita_trie::DB

source ·
pub trait DB {
    // Required methods
    fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Error>;
    fn contains(&self, key: &[u8]) -> Result<bool, Error>;
    fn insert(&self, key: Vec<u8>, value: Vec<u8>) -> Result<(), Error>;
    fn remove(&self, key: &[u8]) -> Result<(), Error>;
    fn flush(&self) -> Result<(), Error>;

    // Provided methods
    fn insert_batch(
        &self,
        keys: Vec<Vec<u8>>,
        values: Vec<Vec<u8>>
    ) -> Result<(), Error> { ... }
    fn remove_batch(&self, keys: &[Vec<u8>]) -> Result<(), Error> { ... }
}
Expand description

“DB” defines the “trait” of trie and database interaction. You should first write the data to the cache and write the data to the database in bulk after the end of a set of operations.

Required Methods§

source

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

source

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

source

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

Insert data into the cache.

source

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

Insert data into the cache.

source

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

Flush data to the DB from the cache.

Provided Methods§

source

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

Insert a batch of data into the cache.

source

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

Remove a batch of data into the cache.

Implementors§