state_engine/ports/
required.rs1use serde_json::Value;
2use std::collections::HashMap;
3
4pub trait InMemoryClient: Send + Sync {
6 fn get(&self, key: &str) -> Option<Value>;
7 fn set(&self, key: &str, value: Value) -> bool;
8 fn delete(&self, key: &str) -> bool;
9}
10
11pub trait KVSClient: Send + Sync {
14 fn get(&self, key: &str) -> Option<String>;
15 fn set(&self, key: &str, value: String, ttl: Option<u64>) -> bool;
17 fn delete(&self, key: &str) -> bool;
18}
19
20pub trait EnvClient: Send + Sync {
23 fn get(&self, key: &str) -> Option<String>;
24 fn set(&self, key: &str, value: String) -> bool;
25 fn delete(&self, key: &str) -> bool;
26}
27
28pub trait DbClient: Send + Sync {
33 fn get(
34 &self,
35 connection: &Value,
36 table: &str,
37 columns: &[&str],
38 where_clause: Option<&str>,
39 ) -> Option<Vec<HashMap<String, Value>>>;
40 fn set(
41 &self,
42 connection: &Value,
43 table: &str,
44 values: &HashMap<String, Value>,
45 where_clause: Option<&str>,
46 ) -> bool;
47 fn delete(
48 &self,
49 connection: &Value,
50 table: &str,
51 where_clause: Option<&str>,
52 ) -> bool;
53}
54
55pub trait HttpClient: Send + Sync {
58 fn get(
59 &self,
60 url: &str,
61 headers: Option<&HashMap<String, String>>,
62 ) -> Option<Value>;
63 fn set(
64 &self,
65 url: &str,
66 body: Value,
67 headers: Option<&HashMap<String, String>>,
68 ) -> bool;
69 fn delete(
70 &self,
71 url: &str,
72 headers: Option<&HashMap<String, String>>,
73 ) -> bool;
74}
75
76pub trait FileClient: Send + Sync {
78 fn get(&self, key: &str) -> Option<String>;
79 fn set(&self, key: &str, value: String) -> bool;
80 fn delete(&self, key: &str) -> bool;
81}