NoSQL

Trait NoSQL 

Source
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§

Source

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.

Source

fn get(&self, key: &str) -> String

get the value with the key inside the database panic if the value if the look up fails.

Source

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.

Source

fn opt_get(&self, key: &str) -> Result<String, Self::Err>

like the get API but return an error if the key is not present

Source

fn opt_put(&self, key: &str, value: &str) -> Result<(), Self::Err>

like the put API bit return and error if this occurs.

Source

fn contains(&self, key: &str) -> bool

check if the key is present inside the database

Source

fn keys(&self) -> Vec<&'static str>

return the list of keys that are insert inside the database.

Implementors§