Trait cfxcore::db::Writable

source ·
pub trait Writable {
    // Required methods
    fn write<T, R>(&mut self, col: u32, key: &dyn Key<T, Target = R>, value: &T)
       where T: Encodable,
             R: Deref<Target = [u8]>;
    fn delete<T, R>(&mut self, col: u32, key: &dyn Key<T, Target = R>)
       where T: Encodable,
             R: Deref<Target = [u8]>;

    // Provided methods
    fn write_with_cache<K, T, R>(
        &mut self,
        col: u32,
        cache: &mut dyn Cache<K, T>,
        key: K,
        value: T,
        policy: CacheUpdatePolicy
    )
       where K: Key<T, Target = R> + Hash + Eq,
             T: Encodable,
             R: Deref<Target = [u8]> { ... }
    fn extend_with_cache<K, T, R>(
        &mut self,
        col: u32,
        cache: &mut dyn Cache<K, T>,
        values: HashMap<K, T>,
        policy: CacheUpdatePolicy
    )
       where K: Key<T, Target = R> + Hash + Eq,
             T: Encodable,
             R: Deref<Target = [u8]> { ... }
    fn extend_with_option_cache<K, T, R>(
        &mut self,
        col: u32,
        cache: &mut dyn Cache<K, Option<T>>,
        values: HashMap<K, Option<T>>,
        policy: CacheUpdatePolicy
    )
       where K: Key<T, Target = R> + Hash + Eq,
             T: Encodable,
             R: Deref<Target = [u8]> { ... }
}
Expand description

Should be used to write value into database.

Required Methods§

source

fn write<T, R>(&mut self, col: u32, key: &dyn Key<T, Target = R>, value: &T)
where T: Encodable, R: Deref<Target = [u8]>,

Writes the value into the database.

source

fn delete<T, R>(&mut self, col: u32, key: &dyn Key<T, Target = R>)
where T: Encodable, R: Deref<Target = [u8]>,

Deletes key from the database.

Provided Methods§

source

fn write_with_cache<K, T, R>( &mut self, col: u32, cache: &mut dyn Cache<K, T>, key: K, value: T, policy: CacheUpdatePolicy )
where K: Key<T, Target = R> + Hash + Eq, T: Encodable, R: Deref<Target = [u8]>,

Writes the value into the database and updates the cache.

source

fn extend_with_cache<K, T, R>( &mut self, col: u32, cache: &mut dyn Cache<K, T>, values: HashMap<K, T>, policy: CacheUpdatePolicy )
where K: Key<T, Target = R> + Hash + Eq, T: Encodable, R: Deref<Target = [u8]>,

Writes the values into the database and updates the cache.

source

fn extend_with_option_cache<K, T, R>( &mut self, col: u32, cache: &mut dyn Cache<K, Option<T>>, values: HashMap<K, Option<T>>, policy: CacheUpdatePolicy )
where K: Key<T, Target = R> + Hash + Eq, T: Encodable, R: Deref<Target = [u8]>,

Writes and removes the values into the database and updates the cache.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Writable for DBTransaction

source§

fn write<T, R>(&mut self, col: u32, key: &dyn Key<T, Target = R>, value: &T)
where T: Encodable, R: Deref<Target = [u8]>,

source§

fn delete<T, R>(&mut self, col: u32, key: &dyn Key<T, Target = R>)
where T: Encodable, R: Deref<Target = [u8]>,

Implementors§