pub struct GraphBuilder<S: StateSchema> { /* private fields */ }Expand description
GraphBuilder - Fluent builder pattern for StateGraph
Implementations§
Source§impl<S: StateSchema + 'static> GraphBuilder<S>
impl<S: StateSchema + 'static> GraphBuilder<S>
Sourcepub fn add_node_fn<F>(self, name: impl Into<String>, func: F) -> Self
pub fn add_node_fn<F>(self, name: impl Into<String>, func: F) -> Self
Add a synchronous function node to the graph.
Sourcepub fn add_async_node<F>(self, name: impl Into<String>, func: F) -> Selfwhere
F: AsyncFn<S> + 'static,
pub fn add_async_node<F>(self, name: impl Into<String>, func: F) -> Selfwhere
F: AsyncFn<S> + 'static,
Add an async function node to the graph.
Sourcepub fn add_subgraph<SubS: StateSchema + 'static>(
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,
) -> Self
pub fn add_subgraph<SubS: StateSchema + 'static>( 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, ) -> Self
Add a subgraph node with input/output mappers.
Sourcepub fn add_subgraph_same_state(
self,
name: impl Into<String>,
subgraph: CompiledGraph<S>,
) -> Self
pub fn add_subgraph_same_state( self, name: impl Into<String>, subgraph: CompiledGraph<S>, ) -> Self
Add a subgraph node that shares the same state type.
Sourcepub fn add_edge(
self,
source: impl Into<String>,
target: impl Into<String>,
) -> Self
pub fn add_edge( self, source: impl Into<String>, target: impl Into<String>, ) -> Self
Add a fixed edge between two nodes.
Sourcepub fn add_conditional_edges(
self,
source: impl Into<String>,
router_name: impl Into<String>,
targets: HashMap<String, String>,
default: Option<String>,
) -> Self
pub fn add_conditional_edges( self, source: impl Into<String>, router_name: impl Into<String>, targets: HashMap<String, String>, default: Option<String>, ) -> Self
Add a conditional edge routed by a named router.
Sourcepub fn add_fan_out(
self,
source: impl Into<String>,
targets: Vec<String>,
) -> Self
pub fn add_fan_out( self, source: impl Into<String>, targets: Vec<String>, ) -> Self
Add a FanOut edge for parallel execution.
Sourcepub fn add_fan_in(self, sources: Vec<String>, target: impl Into<String>) -> Self
pub fn add_fan_in(self, sources: Vec<String>, target: impl Into<String>) -> Self
Add a FanIn edge joining multiple sources into one target.
Sourcepub fn set_entry_point(self, node: impl Into<String>) -> Self
pub fn set_entry_point(self, node: impl Into<String>) -> Self
Set the entry point node for the graph.
Sourcepub fn compile(self) -> GraphResult<CompiledGraph<S>>
pub fn compile(self) -> GraphResult<CompiledGraph<S>>
Compile the graph into an executable CompiledGraph.
Sourcepub fn build(self) -> StateGraph<S>
pub fn build(self) -> StateGraph<S>
Build and return the underlying StateGraph.
Trait Implementations§
Source§impl<S: StateSchema + 'static> Default for GraphBuilder<S>
impl<S: StateSchema + 'static> Default for GraphBuilder<S>
Auto Trait Implementations§
impl<S> !RefUnwindSafe for GraphBuilder<S>
impl<S> !UnwindSafe for GraphBuilder<S>
impl<S> Freeze for GraphBuilder<S>where
StateGraph<S>: Freeze,
impl<S> Send for GraphBuilder<S>where
StateGraph<S>: Send,
impl<S> Sync for GraphBuilder<S>where
StateGraph<S>: Sync,
impl<S> Unpin for GraphBuilder<S>where
StateGraph<S>: Unpin,
impl<S> UnsafeUnpin for GraphBuilder<S>where
StateGraph<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