pub enum Guard {
Spec(Pred),
Custom(Arc<dyn Fn(&FlowCtx<'_>) -> bool + Send + Sync>),
}Expand description
A boolean predicate over (state, marking) — the only predicate type.
Use the constructors (Guard::is_true, Guard::captured,
Guard::called_ok, …) for the serializable closed atoms, or
Guard::custom for a bespoke closure (not serializable).
Variants§
Spec(Pred)
A serializable predicate built from the closed atom set.
Custom(Arc<dyn Fn(&FlowCtx<'_>) -> bool + Send + Sync>)
A code-only escape hatch. Not serializable.
Implementations§
Source§impl Guard
impl Guard
Sourcepub fn eq(key: impl Into<String>, value: impl Into<Value>) -> Self
pub fn eq(key: impl Into<String>, value: impl Into<Value>) -> Self
State key equals the given JSON value.
Sourcepub fn captured<I, S>(fields: I) -> Self
pub fn captured<I, S>(fields: I) -> Self
All of the given state keys are present (extracted slots).
Sourcepub fn resolved(name: impl AsRef<str>) -> Self
pub fn resolved(name: impl AsRef<str>) -> Self
True once an orchestrated agent named name has produced a result
(its {name}:result state key is set). Pairs with the
orchestration call/dispatch/background.
Sourcepub fn all(guards: impl IntoIterator<Item = Guard>) -> Self
pub fn all(guards: impl IntoIterator<Item = Guard>) -> Self
Conjunction.
If every input is a serializable atom, the result is a serializable
Pred::All. If any input is a Guard::custom, the result is itself a
custom guard that evaluates the conjunction at runtime — the custom guard
is never silently dropped (it merely makes the combinator
non-serializable, which surfaces as an error only if you try to serialize
the flow).
Sourcepub fn any(guards: impl IntoIterator<Item = Guard>) -> Self
pub fn any(guards: impl IntoIterator<Item = Guard>) -> Self
Disjunction.
Mirrors Guard::all: custom inputs are preserved as a runtime closure
rather than erased.