pub struct DagGraph { /* private fields */ }Expand description
A parsed and validated directed acyclic graph representing a workflow.
Clone is implemented so the "iteration" node can share one parsed
sub-flow DAG across concurrent loop iterations without re-parsing.
Constructed via DagGraph::from_json. After construction the graph is
guaranteed to be acyclic and self-consistent (all edge source/target IDs exist).
Implementations§
Source§impl DagGraph
impl DagGraph
Sourcepub fn from_json(value: &Value) -> Result<Self>
pub fn from_json(value: &Value) -> Result<Self>
Parse and validate a flow definition from a JSON value.
The expected shape is a { "nodes": [...], "edges": [...] } object
(Dify-compatible format):
{
"nodes": [
{ "id": "fetch", "type": "http-request", "data": { "url": "https://api.example.com" } },
{ "id": "notify", "type": "noop", "data": { "run_if": { "from": "fetch", "path": "ok", "op": "eq", "value": true } } }
],
"edges": [
{ "source": "fetch", "target": "notify" }
]
}Sourcepub fn nodes_in_order(&self) -> impl Iterator<Item = &NodeDef>
pub fn nodes_in_order(&self) -> impl Iterator<Item = &NodeDef>
Returns node definitions in topological order (dependencies first).
Sourcepub fn dependencies_of(&self, id: &str) -> &[String]
pub fn dependencies_of(&self, id: &str) -> &[String]
Returns the direct dependencies of a node by ID.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DagGraph
impl RefUnwindSafe for DagGraph
impl Send for DagGraph
impl Sync for DagGraph
impl Unpin for DagGraph
impl UnsafeUnpin for DagGraph
impl UnwindSafe for DagGraph
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