Skip to main content

worldinterface_core/flowspec/
edge.rs

1//! Edge types for FlowSpec graphs.
2
3use serde::{Deserialize, Serialize};
4
5use crate::id::NodeId;
6
7/// A directed edge between two nodes in a FlowSpec graph.
8#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9pub struct Edge {
10    /// Source node.
11    pub from: NodeId,
12    /// Target node.
13    pub to: NodeId,
14    /// Optional condition on this edge (used with branch nodes).
15    #[serde(default, skip_serializing_if = "Option::is_none")]
16    pub condition: Option<EdgeCondition>,
17}
18
19/// Condition under which an edge is taken.
20#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
21#[serde(rename_all = "snake_case")]
22pub enum EdgeCondition {
23    /// Edge taken when branch evaluates true.
24    BranchTrue,
25    /// Edge taken when branch evaluates false.
26    BranchFalse,
27    /// Unconditional edge (always taken).
28    Always,
29}