use crate::error::{AfterburnerError, Result};
use crate::types::{FuelGauge, OutputValue, ScriptId, ScriptInvocation, ScriptOutcome};
use serde_json::Value;
pub trait Combustor: Send + Sync {
fn ignite(&self, source: &str) -> Result<ScriptId>;
fn thrust(&self, id: &ScriptId, input: &Value, limits: &FuelGauge) -> Result<Value>;
fn thrust_with_cwd(
&self,
id: &ScriptId,
input: &Value,
limits: &FuelGauge,
_cwd: Option<&str>,
) -> Result<Value> {
self.thrust(id, input, limits)
}
fn thrust_raw(&self, id: &ScriptId, input: &[u8], limits: &FuelGauge) -> Result<Value> {
let _ = (id, input, limits);
Err(AfterburnerError::Engine(
"raw input path not implemented for this backend".into(),
))
}
fn thrust_out(&self, id: &ScriptId, input: &Value, limits: &FuelGauge) -> Result<OutputValue> {
self.thrust(id, input, limits).map(OutputValue::Json)
}
fn thrust_raw_out(
&self,
id: &ScriptId,
input: &[u8],
limits: &FuelGauge,
) -> Result<OutputValue> {
let _ = (id, input, limits);
Err(AfterburnerError::Engine(
"raw input path not implemented for this backend".into(),
))
}
fn extinguish(&self, id: &ScriptId);
fn thrust_columnar_bytes(
&self,
id: &ScriptId,
encoded: &[u8],
limits: &FuelGauge,
) -> Result<Vec<u8>> {
let _ = (id, encoded, limits);
Err(AfterburnerError::Engine(
"columnar UDF path not implemented for this backend".into(),
))
}
fn run_script(
&self,
source: &str,
invocation: &ScriptInvocation,
limits: &FuelGauge,
) -> Result<ScriptOutcome> {
let _ = (source, invocation, limits);
Err(AfterburnerError::Engine(
"script mode not supported by this backend".into(),
))
}
}