pub struct StateGraph<S: StateSchema> { /* private fields */ }Expand description
StateGraph - Main graph builder
Manages nodes, edges, and state schema for graph execution. After building, compile to get an executable CompiledGraph.
Implementations§
Source§impl<S: StateSchema + 'static> StateGraph<S>
impl<S: StateSchema + 'static> StateGraph<S>
pub fn new() -> Self
pub fn add_node<N: GraphNode<S> + 'static>(&mut self, node: N) -> &mut Self
pub fn add_node_fn<F>(&mut self, name: impl Into<String>, func: F) -> &mut Self
pub fn add_async_node<F>(
&mut self,
name: impl Into<String>,
func: F,
) -> &mut Selfwhere
F: AsyncFn<S> + 'static,
pub fn add_subgraph<SubS: StateSchema + 'static>( &mut self, name: impl Into<String>, subgraph: CompiledGraph<SubS>, input_mapper: impl Fn(&S) -> SubS + Send + Sync + 'static, output_mapper: impl Fn(&SubS, &mut S) + Send + Sync + 'static, ) -> &mut Self
pub fn add_subgraph_same_state( &mut self, name: impl Into<String>, subgraph: CompiledGraph<S>, ) -> &mut Self
pub fn add_edge( &mut self, source: impl Into<String>, target: impl Into<String>, ) -> &mut Self
pub fn add_conditional_edges( &mut self, source: impl Into<String>, router_name: impl Into<String>, targets: HashMap<String, String>, default: Option<String>, ) -> &mut Self
pub fn add_fan_out( &mut self, source: impl Into<String>, targets: Vec<String>, ) -> &mut Self
pub fn add_fan_in( &mut self, sources: Vec<String>, target: impl Into<String>, ) -> &mut Self
pub fn set_conditional_router<R: ConditionalEdge<S> + 'static>( &mut self, name: impl Into<String>, router: R, ) -> &mut Self
pub fn set_entry_point(&mut self, node: impl Into<String>) -> &mut Self
pub fn set_reducer( &mut self, field: impl Into<String>, reducer: Arc<dyn Reducer<S>>, ) -> &mut Self
pub fn compile(&self) -> GraphResult<CompiledGraph<S>>
Trait Implementations§
Source§impl<S: StateSchema + 'static> Default for StateGraph<S>
impl<S: StateSchema + 'static> Default for StateGraph<S>
Auto Trait Implementations§
impl<S> !RefUnwindSafe for StateGraph<S>
impl<S> !UnwindSafe for StateGraph<S>
impl<S> Freeze for StateGraph<S>
impl<S> Send for StateGraph<S>
impl<S> Sync for StateGraph<S>
impl<S> Unpin for StateGraph<S>
impl<S> UnsafeUnpin for StateGraph<S>where
HashMap<String, Arc<dyn GraphNode<S>>>: UnsafeUnpin,
HashMap<String, Arc<dyn Reducer<S>>>: UnsafeUnpin,
Arc<dyn Reducer<S>>: UnsafeUnpin,
HashMap<String, Arc<dyn ConditionalEdge<S>>>: 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