Skip to main content

LeafNode

Trait LeafNode 

Source
pub trait LeafNode<S: WorkflowState = State>: Send + Sync {
    // Required method
    fn execute<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ctx: &'life1 mut LeafContext<'life2, S>,
    ) -> Pin<Box<dyn Future<Output = Result<(), GraphError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

声明式业务节点 — 只能读 State + emit Mutation。

设计原则:

  • 只能读 Statectx.state() 返回 &S
  • 只能 emit Mutationctx.record()
  • 不能 replace_state / clone_state / fork / merge

ExecutorOperation 完全不同维度:

  • LeafNode = 业务逻辑(Task, Condition, Barrier, LLM, Tool)
  • ExecutorOperation = 执行控制(Parallel, Retry, Loop, SubGraph)

§泛型参数

  • S — 类型化状态(默认 State = HashMap,向后兼容)

Required Methods§

Source

fn execute<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ctx: &'life1 mut LeafContext<'life2, S>, ) -> Pin<Box<dyn Future<Output = Result<(), GraphError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

执行节点逻辑。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S: WorkflowState> LeafNode<S> for BarrierNode<S>

BarrierNode 实现 LeafNode(推荐路径 — 只读 state + pause)。

Source§

impl<S: WorkflowState> LeafNode<S> for ConditionNode<S>

ConditionNode 实现 LeafNode(推荐路径 — 只读 state + goto)。