Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

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