use crate::error::JsonnetError;
use crate::value::JsonnetValue;
pub trait DatabaseHandler {
fn query(&self, query: &str, params: Option<&JsonnetValue>) -> Result<JsonnetValue, JsonnetError>;
fn rewrite(&self, rule: &str, params: Option<&JsonnetValue>) -> Result<JsonnetValue, JsonnetError>;
fn patch(&self, patch: &JsonnetValue) -> Result<JsonnetValue, JsonnetError>;
}
pub struct DefaultDatabaseHandler;
impl DatabaseHandler for DefaultDatabaseHandler {
fn query(&self, _query: &str, _params: Option<&JsonnetValue>) -> Result<JsonnetValue, JsonnetError> {
Err(JsonnetError::runtime_error("Database operations not implemented"))
}
fn rewrite(&self, _rule: &str, _params: Option<&JsonnetValue>) -> Result<JsonnetValue, JsonnetError> {
Err(JsonnetError::runtime_error("Rewrite operations not implemented"))
}
fn patch(&self, _patch: &JsonnetValue) -> Result<JsonnetValue, JsonnetError> {
Err(JsonnetError::runtime_error("Patch operations not implemented"))
}
}