pub struct Graph<S: WorkflowState = State, M: MergeStrategy<S> = StateMerge> { /* private fields */ }Expand description
图(Graph)— 允许有环,循环保护由 GraphExecutor::max_steps 运行时熔断提供。
Implementations§
Source§impl<S: WorkflowState, M: MergeStrategy<S>> Graph<S, M>
impl<S: WorkflowState, M: MergeStrategy<S>> Graph<S, M>
pub fn name(&self) -> &str
pub fn node_names(&self) -> Vec<&str>
pub fn start_node(&self) -> &str
pub fn end_node(&self) -> &str
pub fn edges_from(&self, from: &str) -> Vec<&Edge<S>>
pub fn find_edge(&self, from: &str, to: &str) -> Option<&Edge<S>>
pub fn find_fallback_edge(&self, from: &str) -> Option<String>
Sourcepub fn validate(&self) -> Result<(), TerminalError>
pub fn validate(&self) -> Result<(), TerminalError>
验证图结构。
Sourcepub fn analyze(&self) -> GraphDiagnostics
pub fn analyze(&self) -> GraphDiagnostics
完整图诊断分析。
Sourcepub fn analyze_cycles(&self) -> CycleAnalysis
pub fn analyze_cycles(&self) -> CycleAnalysis
@deprecated 使用 analyze() 替代。
Sourcepub async fn run_inline(
&self,
exec_ctx: &mut ExecutionEngine<S>,
max_steps: usize,
) -> Result<(), GraphError>
pub async fn run_inline( &self, exec_ctx: &mut ExecutionEngine<S>, max_steps: usize, ) -> Result<(), GraphError>
内联执行 — 不产生 RuntimeEvent,不 Checkpoint。
接收 ExecutionEngine(拥有者),内部循环构建 [NodeContext](能力视图)
供节点使用。执行完毕后通过 take_* 消费 Mutation 和控制信号。
数据流:
ExecutionEngine
→ build_node_context() → NodeContext<'_, S>
→ node.execute(ctx) → 节点 record() Mutations
→ drop(ctx) → 释放借用
→ take_mutations() → 消费 Mutation 缓冲
→ state.apply_batch() → apply 到 State
→ take_control() → 获取路由信号Trait Implementations§
Auto Trait Implementations§
impl<S = State, M = StateMerge> !RefUnwindSafe for Graph<S, M>
impl<S = State, M = StateMerge> !UnwindSafe for Graph<S, M>
impl<S, M> Freeze for Graph<S, M>
impl<S, M> Send for Graph<S, M>
impl<S, M> Sync for Graph<S, M>
impl<S, M> Unpin for Graph<S, M>
impl<S, M> UnsafeUnpin for Graph<S, M>
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