pub trait NoSQL {
type Err = Error;
// Required methods
fn new(uri: &str) -> Result<Self, Self::Err>
where Self: Sized;
fn get(&self, key: &str) -> String;
fn put(&self, key: &str, value: &str);
fn opt_get(&self, key: &str) -> Result<String, Self::Err>;
fn opt_put(&self, key: &str, value: &str) -> Result<(), Self::Err>;
fn contains(&self, key: &str) -> bool;
fn keys(&self) -> Vec<&'static str>;
}Expand description
Simple No SQL interface that expose simple sync and async API to interact with the database.
Provided Associated Types§
Required Methods§
Sourcefn new(uri: &str) -> Result<Self, Self::Err>where
Self: Sized,
fn new(uri: &str) -> Result<Self, Self::Err>where
Self: Sized,
create a new instance of the database with the URI provided.
The URI can be a http link or a simple disk path.
Sourcefn get(&self, key: &str) -> String
fn get(&self, key: &str) -> String
get the value with the key inside the database panic if the value if the look up fails.
Sourcefn put(&self, key: &str, value: &str)
fn put(&self, key: &str, value: &str)
put the value inside the database with the key panic is there is any error while communicating with the db.
Sourcefn opt_get(&self, key: &str) -> Result<String, Self::Err>
fn opt_get(&self, key: &str) -> Result<String, Self::Err>
like the get API but return an error
if the key is not present