Skip to main content

CompiledGraph

Struct CompiledGraph 

Source
pub struct CompiledGraph<S: State> { /* private fields */ }
Expand description

The compiled, executable graph.

Implementations§

Source§

impl<S: State> CompiledGraph<S>

Source

pub fn with_checkpointer(self, checkpointer: Arc<dyn Checkpointer>) -> Self

Set a checkpointer for state persistence.

Source

pub async fn invoke(&self, state: S) -> Result<GraphResult<S>, SynapticError>

Execute the graph with initial state.

Source

pub async fn invoke_with_config( &self, state: S, config: Option<CheckpointConfig>, ) -> Result<GraphResult<S>, SynapticError>

Execute with optional checkpoint config for resumption.

Source

pub fn stream(&self, state: S, mode: StreamMode) -> GraphStream<'_, S>

Stream graph execution, yielding a GraphEvent after each node.

Source

pub fn stream_with_config( &self, state: S, _mode: StreamMode, config: Option<CheckpointConfig>, ) -> GraphStream<'_, S>

Stream graph execution with optional checkpoint config.

Source

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.

Source

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.

Source

pub async fn update_state( &self, config: &CheckpointConfig, update: S, ) -> Result<(), SynapticError>

Update state on an interrupted graph (for human-in-the-loop).

Source

pub async fn get_state( &self, config: &CheckpointConfig, ) -> Result<Option<S>, SynapticError>

Get the current state for a thread from the checkpointer.

Returns None if no checkpoint exists for the given thread.

Source

pub async fn get_state_history( &self, config: &CheckpointConfig, ) -> Result<Vec<(S, Option<String>)>, SynapticError>

Get the state history for a thread (all checkpoints).

Returns a list of (state, next_node) pairs, ordered from oldest to newest.

Source

pub fn is_deferred(&self, node_name: &str) -> bool

Returns true if the given node is deferred (waits for all incoming paths).

Source

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>

Source

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
Source

pub fn draw_ascii(&self) -> String

Render the graph as a simple ASCII text summary.

Source

pub fn draw_dot(&self) -> String

Render the graph in Graphviz DOT format.

Source

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.

Source

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.

Source

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>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: State> Display for CompiledGraph<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more