1use crate::error::JsonnetError;
9use crate::value::JsonnetValue;
10
11pub trait DatabaseHandler {
13 fn query(&self, query: &str, params: Option<&JsonnetValue>) -> Result<JsonnetValue, JsonnetError>;
15
16 fn rewrite(&self, rule: &str, params: Option<&JsonnetValue>) -> Result<JsonnetValue, JsonnetError>;
18
19 fn patch(&self, patch: &JsonnetValue) -> Result<JsonnetValue, JsonnetError>;
21}
22
23pub struct DefaultDatabaseHandler;
25
26impl DatabaseHandler for DefaultDatabaseHandler {
27 fn query(&self, _query: &str, _params: Option<&JsonnetValue>) -> Result<JsonnetValue, JsonnetError> {
28 Err(JsonnetError::runtime_error("Database operations not implemented"))
29 }
30
31 fn rewrite(&self, _rule: &str, _params: Option<&JsonnetValue>) -> Result<JsonnetValue, JsonnetError> {
32 Err(JsonnetError::runtime_error("Rewrite operations not implemented"))
33 }
34
35 fn patch(&self, _patch: &JsonnetValue) -> Result<JsonnetValue, JsonnetError> {
36 Err(JsonnetError::runtime_error("Patch operations not implemented"))
37 }
38}