Trait mdl::model::Model[][src]

pub trait Model: Serialize + DeserializeOwned {
    fn key(&self) -> String;

    fn db() -> &'static str { ... }
fn tob(&self) -> Result<Vec<u8>, Error> { ... }
fn fromb(data: &[u8]) -> Result<Self, Error> { ... }
fn store<S: Store>(&self, store: &S) -> Result<(), Error> { ... }
fn store_sig<S: Store, G: Signaler>(
        &self,
        store: &S,
        sig: &G
    ) -> Result<(), Error> { ... }
fn delete<S: Store>(&self, store: &S) -> Result<(), Error> { ... }
fn delete_sig<S: Store, G: Signaler>(
        &self,
        store: &S,
        sig: &G
    ) -> Result<(), Error> { ... }
fn get<S: Store>(store: &S, key: &str) -> Result<Self, Error> { ... }
fn all<S: Store>(store: &S, prefix: &str) -> Result<Vec<Self>, Error> { ... }
fn iter<S, F>(store: &S, prefix: &str, f: F) -> Result<(), Error>
    where
        S: Store,
        F: Fn(Self) -> Continue
, { ... } }

Trait to implement Cacheable data Model

Required Methods

key to identify the data object, this should be unique

Provided Methods

database name, where to store instances of this struct

Data Struct serialization

Data Struct deserialization

Persist the struct in the database

Persist the struct in the database and emit the signal to the signaler

Deletes the object from the database

Deletes the object from the database and emit the signal to the signaler

Loads the struct from the database

Get all objects with this prefix

Iterate over all objects with this prefix

Implementors