pub struct SubgraphSpec<Outer: WorkflowState, Inner: WorkflowState, M: MergeStrategy<Inner>, L: StateLens<Outer, Inner>> {
pub graph: Arc<Graph<Inner, M>>,
pub lens: L,
pub max_steps: usize,
/* private fields */
}Expand description
Fields§
§graph: Arc<Graph<Inner, M>>内层 Graph — Arc 共享,与 AgentBuilder::build() 返回类型一致(D10)。
lens: L状态投影器
max_steps: usize最大执行步数
Implementations§
Source§impl<Outer, Inner, M, L> SubgraphSpec<Outer, Inner, M, L>where
Outer: 'static + WorkflowState,
Inner: 'static + WorkflowState,
M: 'static + MergeStrategy<Inner>,
L: 'static + StateLens<Outer, Inner>,
impl<Outer, Inner, M, L> SubgraphSpec<Outer, Inner, M, L>where
Outer: 'static + WorkflowState,
Inner: 'static + WorkflowState,
M: 'static + MergeStrategy<Inner>,
L: 'static + StateLens<Outer, Inner>,
Sourcepub fn project<'a>(&self, outer: &'a mut Outer) -> &'a mut Inner
pub fn project<'a>(&self, outer: &'a mut Outer) -> &'a mut Inner
通过 Lens 投影状态。
从外层 State 投影出内层 State 的可变引用。
Sourcepub fn compile(self) -> CompiledSubgraph<Outer>
pub fn compile(self) -> CompiledSubgraph<Outer>
编译为 CompiledSubgraph — 类型擦除 Inner/Lens/M。
Trait Implementations§
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>,
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>,
Source§fn execute<'a>(
&'a self,
outer: &'a mut Outer,
stream: Option<Arc<dyn StreamSink>>,
cancel: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<(), GraphError>> + Send + 'a>>
fn execute<'a>( &'a self, outer: &'a mut Outer, stream: Option<Arc<dyn StreamSink>>, cancel: CancellationToken, ) -> Pin<Box<dyn Future<Output = Result<(), GraphError>> + Send + 'a>>
执行 Subgraph — 投影状态 + 递归执行内层 Graph。
§执行流程
- 通过 Lens 投影出内层 State(
&mut Inner) - 创建内层 ExecutionEngine(借用
&mut Inner) - 调用
graph.run_inline() - inner_engine drop → 借用释放 → outer 可继续使用
Source§fn graph_name(&self) -> &str
fn graph_name(&self) -> &str
内层 Graph 的名称。
Source§fn node_count(&self) -> usize
fn node_count(&self) -> usize
内层 Graph 的节点数(用于评估是否值得内联)。
Auto Trait Implementations§
impl<Outer, Inner, M, L> !RefUnwindSafe for SubgraphSpec<Outer, Inner, M, L>
impl<Outer, Inner, M, L> !UnwindSafe for SubgraphSpec<Outer, Inner, M, L>
impl<Outer, Inner, M, L> Freeze for SubgraphSpec<Outer, Inner, M, L>where
L: Freeze,
impl<Outer, Inner, M, L> Send for SubgraphSpec<Outer, Inner, M, L>
impl<Outer, Inner, M, L> Sync for SubgraphSpec<Outer, Inner, M, L>
impl<Outer, Inner, M, L> Unpin for SubgraphSpec<Outer, Inner, M, L>
impl<Outer, Inner, M, L> UnsafeUnpin for SubgraphSpec<Outer, Inner, M, L>where
L: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more