zen_engine/nodes/input/
mod.rs

1use crate::nodes::definition::NodeHandler;
2use crate::nodes::result::NodeResult;
3use crate::nodes::NodeContext;
4use zen_types::decision::InputNodeContent;
5use zen_types::variable::Variable;
6
7#[derive(Debug, Clone)]
8pub struct InputNodeHandler;
9
10pub type InputNodeData = InputNodeContent;
11pub type InputNodeTrace = Variable;
12
13impl NodeHandler for InputNodeHandler {
14    type NodeData = InputNodeData;
15    type TraceData = InputNodeTrace;
16
17    async fn handle(&self, ctx: NodeContext<Self::NodeData, Self::TraceData>) -> NodeResult {
18        if let Some(json_schema) = &ctx.node.schema {
19            let input_json = ctx.input.to_value();
20            ctx.validate(json_schema, &input_json)?;
21        };
22
23        ctx.success(ctx.input.clone())
24    }
25}