[][src]Trait mdl::store::Store

pub trait Store {
    fn push(
        &self,
        db: &'static str,
        key: &str,
        value: Vec<u8>
    ) -> Result<(), Error>;
fn pull<F, T>(
        &self,
        db: &'static str,
        key: &str,
        formatter: F
    ) -> Result<T, Error>
    where
        F: Fn(&[u8]) -> Result<T, Error>
;
fn iter<F>(&self, db: &'static str, prefix: &str, f: F) -> Result<(), Error>
    where
        F: Fn(&[u8]) -> Continue
;
fn rm(&self, db: &'static str, key: &str) -> Result<(), Error>; fn all<F, T>(
        &self,
        db: &'static str,
        prefix: &str,
        formatter: F
    ) -> Result<Vec<T>, Error>
    where
        F: Fn(&[u8]) -> Result<T, Error>
, { ... } }

Trait that defines a Store that can be implemented to save Model objects in memory, filesystem or the network

Required methods

fn push(&self, db: &'static str, key: &str, value: Vec<u8>) -> Result<(), Error>

Stores the value in the database with the corresponding key

fn pull<F, T>(
    &self,
    db: &'static str,
    key: &str,
    formatter: F
) -> Result<T, Error> where
    F: Fn(&[u8]) -> Result<T, Error>, 

Retrieves the value in the database with the corresponding key Returns an error if the key doesn't exists

fn iter<F>(&self, db: &'static str, prefix: &str, f: F) -> Result<(), Error> where
    F: Fn(&[u8]) -> Continue

Iterates over all objects that starts with the prefix and run the function f. If f returns Continue(false) the iteration stops

fn rm(&self, db: &'static str, key: &str) -> Result<(), Error>

Remove the corresponding data in the database by key

Loading content...

Provided methods

fn all<F, T>(
    &self,
    db: &'static str,
    prefix: &str,
    formatter: F
) -> Result<Vec<T>, Error> where
    F: Fn(&[u8]) -> Result<T, Error>, 

Retrieves all items in the database that starts with the prefix key

Loading content...

Implementors

impl Store for mdl::bcache::Cache[src]

impl Store for mdl::cache::Cache[src]

Loading content...