pub enum Condition<S> {
Always,
Never,
OnSkip,
OnError,
Named(NamedConditionId),
And(Vec<Condition<S>>),
Or(Vec<Condition<S>>),
Not(Box<Condition<S>>),
Custom {
label: String,
f: ConditionFn<S>,
},
}Expand description
A declarative predicate deciding whether an edge fires.
The engine evaluates a completed node’s outgoing edges in declaration order; every
edge whose condition matches fires (emits an activation token). Write mutually
exclusive conditions for branch selection — e.g. an is_done / not_done named pair —
and prefer an Condition::Always fallback so a node can never strand into a dead-end.
The S parameter appears only in the Condition::Custom escape hatch; the
serializable subset is entirely S-free (see crate::def::ConditionDef).
Variants§
Always
Always fires when the source completes successfully (the dataflow-profile default).
Never
Never fires. Useful to park an edge in a saved graph without deleting it.
OnSkip
Fires when the source execution carried a BspSkip marker (dataflow profile).
OnError
Fires when the source node failed and its recovery policy is
crate::recovery::RecoveryPolicy::RouteToErrorEdge. Error paths become visible,
GUI-renderable topology instead of implicit aborts.
Named(NamedConditionId)
Consumer-registered named predicate over &S + value store.
And(Vec<Condition<S>>)
Ordered short-circuit conjunction over conditions.
Or(Vec<Condition<S>>)
Ordered short-circuit disjunction over conditions.
Not(Box<Condition<S>>)
Negation of a condition.
Custom
Escape hatch for the long tail. Never serializes its closure: the definition layer
keeps only label, and instantiation fails closed unless a condition with that
label is re-registered. The GUI renders it as an opaque gray box. Use sparingly.
Fields
f: ConditionFn<S>The predicate over consumer state and value store.
Implementations§
Source§impl<S> Condition<S>
impl<S> Condition<S>
Sourcepub fn eval(&self, ctx: &ConditionEval<'_, S>) -> bool
pub fn eval(&self, ctx: &ConditionEval<'_, S>) -> bool
Evaluates the condition in the given context.
A missing Condition::Named registration evaluates to false; graph validation
(crate::engine::BspEngine::validate_with_report / BspGraph::from_def) reports
unknown names loudly before a run ever starts.
Sourcepub fn label(&self) -> String
pub fn label(&self) -> String
A short human-readable label for interceptor events and GUI badges.
Sourcepub fn collect_named(&self, out: &mut Vec<String>)
pub fn collect_named(&self, out: &mut Vec<String>)
Collects every named-condition reference in this condition tree.
Used by validation to check registry completeness.
Sourcepub fn collect_custom_labels(&self, out: &mut Vec<String>)
pub fn collect_custom_labels(&self, out: &mut Vec<String>)
Collects the labels of every Condition::Custom leaf in this condition tree.
Custom closures do not serialize; definitions carrying them fail closed at instantiation unless the label is registered as a named condition.