use serde_json::Value;
use std::collections::HashMap;
pub trait InMemoryClient: Send + Sync {
fn get(&self, key: &str) -> Option<Value>;
fn set(&self, key: &str, value: Value) -> bool;
fn delete(&self, key: &str) -> bool;
}
pub trait KVSClient: Send + Sync {
fn get(&self, key: &str) -> Option<String>;
fn set(&self, key: &str, value: String, ttl: Option<u64>) -> bool;
fn delete(&self, key: &str) -> bool;
}
pub trait EnvClient: Send + Sync {
fn get(&self, key: &str) -> Option<String>;
fn set(&self, key: &str, value: String) -> bool;
fn delete(&self, key: &str) -> bool;
}
pub trait DbClient: Send + Sync {
fn get(
&self,
connection: &Value,
table: &str,
columns: &[&str],
where_clause: Option<&str>,
) -> Option<Vec<HashMap<String, Value>>>;
fn set(
&self,
connection: &Value,
table: &str,
values: &HashMap<String, Value>,
where_clause: Option<&str>,
) -> bool;
fn delete(
&self,
connection: &Value,
table: &str,
where_clause: Option<&str>,
) -> bool;
}
pub trait HttpClient: Send + Sync {
fn get(
&self,
url: &str,
headers: Option<&HashMap<String, String>>,
) -> Option<Value>;
fn set(
&self,
url: &str,
body: Value,
headers: Option<&HashMap<String, String>>,
) -> bool;
fn delete(
&self,
url: &str,
headers: Option<&HashMap<String, String>>,
) -> bool;
}
pub trait FileClient: Send + Sync {
fn get(&self, key: &str) -> Option<String>;
fn set(&self, key: &str, value: String) -> bool;
fn delete(&self, key: &str) -> bool;
}