pub trait Store {
// Required methods
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>;
// Provided method
fn all<F, T>(
&self,
db: &'static str,
prefix: &str,
formatter: F,
) -> Result<Vec<T>, Error>
where F: Fn(&[u8]) -> Result<T, Error> { ... }
}
Expand description
Trait that defines a Store that can be implemented to save Model objects in memory, filesystem or the network
Required Methods§
Sourcefn push(&self, db: &'static str, key: &str, value: Vec<u8>) -> Result<(), Error>
fn push(&self, db: &'static str, key: &str, value: Vec<u8>) -> Result<(), Error>
Stores the value in the database with the corresponding key
Sourcefn pull<F, T>(
&self,
db: &'static str,
key: &str,
formatter: F,
) -> Result<T, Error>
fn pull<F, T>( &self, db: &'static str, key: &str, formatter: F, ) -> Result<T, Error>
Retrieves the value in the database with the corresponding key Returns an error if the key doesn’t exists
Provided Methods§
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.