Skip to main content

StateProjector

Trait StateProjector 

Source
pub trait StateProjector<S: WorkflowState>: Send + Sync {
    // Required methods
    fn execute<'a>(
        &'a self,
        outer: &'a mut S,
        stream: Option<Arc<dyn StreamSink>>,
        cancel: CancellationToken,
    ) -> Pin<Box<dyn Future<Output = Result<(), GraphError>> + Send + 'a>>;
    fn graph_name(&self) -> &str;
    fn node_count(&self) -> usize;
}
Expand description

状态投影器 — 类型擦除的 Outer → Inner 投影 + 执行。

这是 Subgraph 执行的核心 trait。它擦除了 Inner、Lens、Merge 类型, 只暴露 Outer State 类型。

§设计原则

  • 最小接口:只有 execute() + 元数据方法
  • 类型擦除:Inner/Lens/M 全部隐藏在实现内部
  • 可 introspection:提供 graph_name()node_count()

Required Methods§

Source

fn execute<'a>( &'a self, outer: &'a mut S, stream: Option<Arc<dyn StreamSink>>, cancel: CancellationToken, ) -> Pin<Box<dyn Future<Output = Result<(), GraphError>> + Send + 'a>>

执行 Subgraph — 投影状态 + 递归执行内层 Graph。

Source

fn graph_name(&self) -> &str

内层 Graph 的名称。

Source

fn node_count(&self) -> usize

内层 Graph 的节点数(用于评估是否值得内联)。

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<Outer: WorkflowState, Inner, M, L> StateProjector<Outer> for SubgraphSpec<Outer, Inner, M, L>
where Inner: 'static + WorkflowState, M: 'static + MergeStrategy<Inner>, L: 'static + StateLens<Outer, Inner>,