zen_engine/handler/
node.rs1use crate::model::DecisionNode;
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4use std::fmt::{Display, Formatter};
5use std::sync::Arc;
6use thiserror::Error;
7use zen_expression::variable::Variable;
8
9#[derive(Debug, Deserialize, Serialize)]
10#[serde(rename_all = "camelCase")]
11pub struct NodeResponse {
12 pub output: Variable,
13 pub trace_data: Option<Value>,
14}
15
16#[derive(Debug, Serialize, Clone)]
17pub struct NodeRequest {
18 pub input: Variable,
19 pub iteration: u8,
20 pub node: Arc<DecisionNode>,
21}
22
23#[derive(Error, Debug)]
24pub struct NodeError {
25 pub node_id: String,
26 pub trace: Option<Value>,
27 #[source]
28 pub source: anyhow::Error,
29}
30
31impl Display for NodeError {
32 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
33 write!(f, "{:?}", self)
34 }
35}
36
37#[derive(Debug)]
38pub(crate) struct PartialTraceError {
39 pub trace: Option<Value>,
40 pub message: String,
41}
42
43impl Display for PartialTraceError {
44 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
45 write!(f, "{}", self.message)
46 }
47}
48
49pub type NodeResult = anyhow::Result<NodeResponse>;