pub struct BspGraph<S = ()> { /* private fields */ }Expand description
The blueprint definition containing nodes, edges, and initial inputs.
S is the consumer-owned run state the graph’s nodes operate on; it defaults to ()
for pure dataflow graphs.
Implementations§
Source§impl<S> BspGraph<S>
impl<S> BspGraph<S>
Sourcepub fn from_def(
def: &GraphDef,
registry: &NodeRegistry<S>,
ctx: &BspContext,
) -> Result<Self, BspError>
pub fn from_def( def: &GraphDef, registry: &NodeRegistry<S>, ctx: &BspContext, ) -> Result<Self, BspError>
Instantiates a graph from a serializable definition and a consumer registry.
Registration is fail-fast: any unknown node type_name, condition name, custom
label, or merger name produces a BspError::ValidationError listing all
unknown names — never a mid-run surprise. Node and edge ids are mapped from the
definition’s stable strings onto positional NodeIds, with the strings retained
as labels so BspGraph::to_def round-trips losslessly.
Sourcepub fn to_def(&self) -> GraphDef
pub fn to_def(&self) -> GraphDef
Projects this graph into a serializable definition.
Def-built graphs re-emit their retained NodeDefs exactly, so
def -> graph -> def is a fixed point. Programmatically built graphs synthesize
node definitions from the live nodes (stable label ids, type_names, current
activation / recovery / merger / execution caps, null configs).
Source§impl<S> BspGraph<S>
impl<S> BspGraph<S>
Sourcepub fn add_node<N: BspNode<S> + 'static>(
&mut self,
node: N,
) -> TypedNodeHandle<N>
pub fn add_node<N: BspNode<S> + 'static>( &mut self, node: N, ) -> TypedNodeHandle<N>
Registers a node with a self-assigned auto-incrementing identifier.
Sourcepub fn add_node_with_id(
&mut self,
id: impl Into<NodeId>,
node: Box<dyn BspNode<S>>,
)
pub fn add_node_with_id( &mut self, id: impl Into<NodeId>, node: Box<dyn BspNode<S>>, )
Registers a node within the graph’s designated manual identifier namespace.
Sourcepub fn add_link(&mut self, source: OutputPin, target: InputPin)
pub fn add_link(&mut self, source: OutputPin, target: InputPin)
Connects an output pin of a source node to an input pin of a target node.
This is the dataflow profile’s wiring primitive: an edge with
Condition::Always carrying both ports.
Sourcepub fn add_link_indices(
&mut self,
source_node: NodeId,
source_port: PortIndex,
target_node: NodeId,
target_port: PortIndex,
)
pub fn add_link_indices( &mut self, source_node: NodeId, source_port: PortIndex, target_node: NodeId, target_port: PortIndex, )
Back-compatible helper targeting index indices.
Sourcepub fn add_edge(
&mut self,
source: impl Into<NodeId>,
target: impl Into<NodeId>,
) -> EdgeBuilder<'_, S>
pub fn add_edge( &mut self, source: impl Into<NodeId>, target: impl Into<NodeId>, ) -> EdgeBuilder<'_, S>
Adds a control-flow edge between two nodes, returning a builder for the condition
and iteration budget. The default condition is Condition::Always.
Sourcepub fn add_edge_with(
&mut self,
source: impl Into<NodeId>,
target: impl Into<NodeId>,
condition: Condition<S>,
) -> EdgeId
pub fn add_edge_with( &mut self, source: impl Into<NodeId>, target: impl Into<NodeId>, condition: Condition<S>, ) -> EdgeId
Adds a control-flow edge with an explicit condition in one call.
Sourcepub fn set_static_input<T: Any + Send + Sync>(
&mut self,
target: InputPin,
value: T,
)
pub fn set_static_input<T: Any + Send + Sync>( &mut self, target: InputPin, value: T, )
Injects an initial static parameter into a specific node’s input pin.
Sourcepub fn register_condition(
&mut self,
name: impl Into<String>,
f: impl Fn(&S, &ValueStore) -> bool + Send + Sync + 'static,
)
pub fn register_condition( &mut self, name: impl Into<String>, f: impl Fn(&S, &ValueStore) -> bool + Send + Sync + 'static, )
Registers a named condition predicate (the serializable routing mechanism).
Sourcepub fn register_merger<M: Merger<S> + 'static>(
&mut self,
name: impl Into<String>,
merger: M,
)
pub fn register_merger<M: Merger<S> + 'static>( &mut self, name: impl Into<String>, merger: M, )
Registers a named merger used by join nodes to fold branch states.
Sourcepub fn add_entry(&mut self, id: impl Into<NodeId>)
pub fn add_entry(&mut self, id: impl Into<NodeId>)
Marks a node as an explicit entry (in addition to no-incoming-edge sources).
Sourcepub fn node_label(&self, id: NodeId) -> Option<&str>
pub fn node_label(&self, id: NodeId) -> Option<&str>
The stable string label for a node (its crate::def::NodeDef id).
Sourcepub fn node_ids(&self) -> impl Iterator<Item = NodeId> + '_
pub fn node_ids(&self) -> impl Iterator<Item = NodeId> + '_
The nodes of this graph, in declaration order.