Skip to main content

CacheDb

Trait CacheDb 

Source
pub trait CacheDb<S>:
    Clone
    + Send
    + Sync
where S: Dto,
{ // Required methods fn get_from_db( &self, prefix: Option<&str>, key: &ModelKey, ) -> Result<Option<String>, DbError>; fn set_in_db( &self, prefix: Option<&str>, key: &ModelKey, state: String, ) -> Result<(), DbError>; // Provided methods fn get( &self, prefix: Option<&str>, key: &ModelKey, ) -> Result<ModelWithPosition<S>, DbError> { ... } fn set( &self, key: &ModelKey, data: ModelWithPosition<S>, prefix: Option<&str>, ) -> Result<(), DbError> { ... } }
Expand description

CacheDb has only one purpose, reading and writing state somewhere

Required Methods§

Source

fn get_from_db( &self, prefix: Option<&str>, key: &ModelKey, ) -> Result<Option<String>, DbError>

internal function to read from the db

§Errors

Will return Err if any error append when calling the DB.

Source

fn set_in_db( &self, prefix: Option<&str>, key: &ModelKey, state: String, ) -> Result<(), DbError>

internal function to write in the db

§Errors

Will return Err if any error append when calling the DB.

Provided Methods§

Source

fn get( &self, prefix: Option<&str>, key: &ModelKey, ) -> Result<ModelWithPosition<S>, DbError>

public function to read the db

§Errors

Will return Err if any error append when calling the DB.

Source

fn set( &self, key: &ModelKey, data: ModelWithPosition<S>, prefix: Option<&str>, ) -> Result<(), DbError>

public function to write in the db

§Errors

Will return Err if any error append when calling the DB.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S> CacheDb<S> for NoCache<S>
where S: Dto,

Source§

impl<S> CacheDb<S> for StateDb<S>
where S: Dto,