mirror of
https://github.com/gorules/zen.git
synced 2026-10-04 00:02:18 +00:00
* feat: custom node * add zen template, expose $nodes and $root * add custom handler to go and nodejs * add support for python, improve bindings, add error to zen template * fix: correct binding exports for nodejs and python * fix benchmark * improve rust api, trim template in zen templates * update cargo action * update expression version * compile action * fix action format
35 lines
756 B
Rust
35 lines
756 B
Rust
use crate::model::DecisionNode;
|
|
use serde::{Deserialize, Serialize};
|
|
use serde_json::Value;
|
|
use std::fmt::{Display, Formatter};
|
|
use thiserror::Error;
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct NodeResponse {
|
|
pub output: Value,
|
|
pub trace_data: Option<Value>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct NodeRequest<'a> {
|
|
pub input: Value,
|
|
pub iteration: u8,
|
|
pub node: &'a DecisionNode,
|
|
}
|
|
|
|
#[derive(Error, Debug)]
|
|
pub struct NodeError {
|
|
pub node_id: String,
|
|
#[source]
|
|
pub source: anyhow::Error,
|
|
}
|
|
|
|
impl Display for NodeError {
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "{:?}", self)
|
|
}
|
|
}
|
|
|
|
pub type NodeResult = anyhow::Result<NodeResponse>;
|