af_workflow/result.rs
1//! What a step node returns. Port of `platform/types.py` Pass / Drop / FanOut.
2
3use crate::event::Event;
4
5/// The outcome of running one event through one [`crate::node::StepNode`].
6#[derive(Debug, Clone)]
7pub enum StepResult {
8 /// Forward the (possibly derived) event to the next step.
9 Pass(Event),
10 /// Stop propagation here. Filters and sink terminals return this.
11 Drop {
12 reason: String,
13 /// Stable machine-readable code for material business outcomes. A
14 /// routine filter drop leaves this empty.
15 exit_reason: Option<String>,
16 },
17 /// Forward several events. Only nodes that declare `produces_fan_out`
18 /// may return this; the validator bans fan-out upstream of `execute.*`.
19 FanOut(Vec<Event>),
20}
21
22impl StepResult {
23 pub fn drop(reason: impl Into<String>) -> Self {
24 StepResult::Drop {
25 reason: reason.into(),
26 exit_reason: None,
27 }
28 }
29
30 /// A material gate/drop that recorders should persist as a run step.
31 pub fn gate(exit_reason: impl Into<String>) -> Self {
32 let code = exit_reason.into();
33 StepResult::Drop {
34 reason: code.clone(),
35 exit_reason: Some(code),
36 }
37 }
38}