Trait cfxcore::db::Readable

source ·
pub trait Readable {
    // Required methods
    fn read<T, R>(&self, col: u32, key: &dyn Key<T, Target = R>) -> Option<T>
       where T: Decodable,
             R: Deref<Target = [u8]>;
    fn exists<T, R>(&self, col: u32, key: &dyn Key<T, Target = R>) -> bool
       where R: Deref<Target = [u8]>;

    // Provided methods
    fn read_with_cache<K, T, C>(
        &self,
        col: u32,
        cache: &RwLock<C>,
        key: &K
    ) -> Option<T>
       where K: Key<T> + Eq + Hash + Clone,
             T: Clone + Decodable,
             C: Cache<K, T> { ... }
    fn exists_with_cache<K, T, R, C>(
        &self,
        col: u32,
        cache: &RwLock<C>,
        key: &K
    ) -> bool
       where K: Eq + Hash + Key<T, Target = R>,
             R: Deref<Target = [u8]>,
             C: Cache<K, T> { ... }
}
Expand description

Should be used to read values from database.

Required Methods§

source

fn read<T, R>(&self, col: u32, key: &dyn Key<T, Target = R>) -> Option<T>
where T: Decodable, R: Deref<Target = [u8]>,

Returns value for given key.

source

fn exists<T, R>(&self, col: u32, key: &dyn Key<T, Target = R>) -> bool
where R: Deref<Target = [u8]>,

Returns true if given value exists.

Provided Methods§

source

fn read_with_cache<K, T, C>( &self, col: u32, cache: &RwLock<C>, key: &K ) -> Option<T>
where K: Key<T> + Eq + Hash + Clone, T: Clone + Decodable, C: Cache<K, T>,

Returns value for given key either in cache or in database.

source

fn exists_with_cache<K, T, R, C>( &self, col: u32, cache: &RwLock<C>, key: &K ) -> bool
where K: Eq + Hash + Key<T, Target = R>, R: Deref<Target = [u8]>, C: Cache<K, T>,

Returns true if given value exists either in cache or in database.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<KVDB: KeyValueDB + ?Sized> Readable for KVDB