pub struct CompiledGraph<S: State> { /* private fields */ }Expand description
The compiled, executable graph.
Implementations§
Source§impl<S: State> CompiledGraph<S>
impl<S: State> CompiledGraph<S>
Sourcepub fn with_checkpointer(self, checkpointer: Arc<dyn Checkpointer>) -> Self
pub fn with_checkpointer(self, checkpointer: Arc<dyn Checkpointer>) -> Self
Set a checkpointer for state persistence.
Sourcepub async fn invoke(&self, state: S) -> Result<GraphResult<S>, SynapticError>where
S: Serialize + DeserializeOwned,
pub async fn invoke(&self, state: S) -> Result<GraphResult<S>, SynapticError>where
S: Serialize + DeserializeOwned,
Execute the graph with initial state.
Sourcepub async fn invoke_with_config(
&self,
state: S,
config: Option<CheckpointConfig>,
) -> Result<GraphResult<S>, SynapticError>where
S: Serialize + DeserializeOwned,
pub async fn invoke_with_config(
&self,
state: S,
config: Option<CheckpointConfig>,
) -> Result<GraphResult<S>, SynapticError>where
S: Serialize + DeserializeOwned,
Execute with optional checkpoint config for resumption.
Sourcepub fn stream(&self, state: S, mode: StreamMode) -> GraphStream<'_, S>
pub fn stream(&self, state: S, mode: StreamMode) -> GraphStream<'_, S>
Stream graph execution, yielding a GraphEvent after each node.
Sourcepub fn stream_with_config(
&self,
state: S,
_mode: StreamMode,
config: Option<CheckpointConfig>,
) -> GraphStream<'_, S>
pub fn stream_with_config( &self, state: S, _mode: StreamMode, config: Option<CheckpointConfig>, ) -> GraphStream<'_, S>
Stream graph execution with optional checkpoint config.
Sourcepub fn stream_modes(
&self,
state: S,
modes: Vec<StreamMode>,
) -> MultiGraphStream<'_, S>
pub fn stream_modes( &self, state: S, modes: Vec<StreamMode>, ) -> MultiGraphStream<'_, S>
Stream graph execution with multiple stream modes.
Each event is tagged with the StreamMode that produced it.
For a single node execution, one event per requested mode is emitted.
Sourcepub fn stream_modes_with_config(
&self,
state: S,
modes: Vec<StreamMode>,
config: Option<CheckpointConfig>,
) -> MultiGraphStream<'_, S>
pub fn stream_modes_with_config( &self, state: S, modes: Vec<StreamMode>, config: Option<CheckpointConfig>, ) -> MultiGraphStream<'_, S>
Stream graph execution with multiple stream modes and optional checkpoint config.
Sourcepub async fn update_state(
&self,
config: &CheckpointConfig,
update: S,
) -> Result<(), SynapticError>where
S: Serialize + DeserializeOwned,
pub async fn update_state(
&self,
config: &CheckpointConfig,
update: S,
) -> Result<(), SynapticError>where
S: Serialize + DeserializeOwned,
Update state on an interrupted graph (for human-in-the-loop).
Sourcepub async fn get_state(
&self,
config: &CheckpointConfig,
) -> Result<Option<S>, SynapticError>where
S: DeserializeOwned,
pub async fn get_state(
&self,
config: &CheckpointConfig,
) -> Result<Option<S>, SynapticError>where
S: DeserializeOwned,
Get the current state for a thread from the checkpointer.
Returns None if no checkpoint exists for the given thread.
Sourcepub async fn get_state_history(
&self,
config: &CheckpointConfig,
) -> Result<Vec<(S, Option<String>)>, SynapticError>where
S: DeserializeOwned,
pub async fn get_state_history(
&self,
config: &CheckpointConfig,
) -> Result<Vec<(S, Option<String>)>, SynapticError>where
S: DeserializeOwned,
Get the state history for a thread (all checkpoints).
Returns a list of (state, next_node) pairs, ordered from oldest to newest.
Sourcepub fn is_deferred(&self, node_name: &str) -> bool
pub fn is_deferred(&self, node_name: &str) -> bool
Returns true if the given node is deferred (waits for all incoming paths).
Sourcepub fn incoming_edge_count(&self, node_name: &str) -> usize
pub fn incoming_edge_count(&self, node_name: &str) -> usize
Returns the number of incoming edges (fixed + conditional) for a node.
Source§impl<S: State> CompiledGraph<S>
impl<S: State> CompiledGraph<S>
Sourcepub fn draw_mermaid(&self) -> String
pub fn draw_mermaid(&self) -> String
Render the graph as a Mermaid flowchart string.
__start__and__end__are rendered as rounded nodes([...])- User nodes are rendered as rectangles
[...] - Fixed edges use solid arrows
--> - Conditional edges with path_map use dashed arrows
-.->with labels - Conditional edges without path_map emit a Mermaid comment
Sourcepub fn draw_ascii(&self) -> String
pub fn draw_ascii(&self) -> String
Render the graph as a simple ASCII text summary.
Sourcepub async fn draw_mermaid_png(
&self,
path: impl AsRef<Path>,
) -> Result<(), SynapticError>
pub async fn draw_mermaid_png( &self, path: impl AsRef<Path>, ) -> Result<(), SynapticError>
Render the Mermaid diagram as an image via the mermaid.ink API.
Requires internet access. The generated Mermaid text is URL-safe base64-encoded
and sent to https://mermaid.ink/img/{encoded}. The image (JPEG format) is
written to the specified file path.
Note: mermaid.ink returns JPEG from the /img/ endpoint. For SVG output,
use draw_mermaid_svg instead.
Sourcepub async fn draw_mermaid_svg(
&self,
path: impl AsRef<Path>,
) -> Result<(), SynapticError>
pub async fn draw_mermaid_svg( &self, path: impl AsRef<Path>, ) -> Result<(), SynapticError>
Render the Mermaid diagram as an SVG image via the mermaid.ink API.
Requires internet access. The generated Mermaid text is URL-safe base64-encoded
and sent to https://mermaid.ink/svg/{encoded}. The SVG response is written
to the specified file path.
Sourcepub fn draw_png(&self, path: impl AsRef<Path>) -> Result<(), SynapticError>
pub fn draw_png(&self, path: impl AsRef<Path>) -> Result<(), SynapticError>
Render the graph as a PNG image using the Graphviz dot command.
Requires dot (Graphviz) to be installed and available in $PATH.
The DOT output is piped to dot -Tpng and the resulting PNG is written
to the specified file path.
Trait Implementations§
Source§impl<S: State> Debug for CompiledGraph<S>
impl<S: State> Debug for CompiledGraph<S>
Auto Trait Implementations§
impl<S> Freeze for CompiledGraph<S>
impl<S> !RefUnwindSafe for CompiledGraph<S>
impl<S> Send for CompiledGraph<S>
impl<S> Sync for CompiledGraph<S>
impl<S> Unpin for CompiledGraph<S>
impl<S> UnsafeUnpin for CompiledGraph<S>
impl<S> !UnwindSafe for CompiledGraph<S>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.