Skip to main content

BspGraph

Struct BspGraph 

Source
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>

Source

pub fn from_def( def: &GraphDef, registry: &NodeRegistry<S>, ctx: &BspContext, ) -> Result<Self, BspError>
where S: Send + Sync + 'static,

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.

Source

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>

Source

pub fn new() -> Self

Instantiates a new empty BSP execution graph.

Source

pub fn add_node<N: BspNode<S> + 'static>( &mut self, node: N, ) -> TypedNodeHandle<N>

Registers a node with a self-assigned auto-incrementing identifier.

Source

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.

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.

Back-compatible helper targeting index indices.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn add_entry(&mut self, id: impl Into<NodeId>)

Marks a node as an explicit entry (in addition to no-incoming-edge sources).

Source

pub fn node_label(&self, id: NodeId) -> Option<&str>

The stable string label for a node (its crate::def::NodeDef id).

Source

pub fn node_ids(&self) -> impl Iterator<Item = NodeId> + '_

The nodes of this graph, in declaration order.

Source

pub fn edges(&self) -> &[Edge<S>]

The edges of this graph, in declaration order.

Source

pub fn with_node_id( self, id: impl Into<NodeId>, node: Box<dyn BspNode<S>>, ) -> Self

Source

pub fn with_static_input<T: Any + Send + Sync>( self, target: InputPin, value: T, ) -> Self

Source

pub fn with_condition( self, name: impl Into<String>, f: impl Fn(&S, &ValueStore) -> bool + Send + Sync + 'static, ) -> Self

Source

pub fn with_merger<M: Merger<S> + 'static>( self, name: impl Into<String>, merger: M, ) -> Self

Trait Implementations§

Source§

impl<S> Default for BspGraph<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S = ()> !RefUnwindSafe for BspGraph<S>

§

impl<S = ()> !UnwindSafe for BspGraph<S>

§

impl<S> Freeze for BspGraph<S>

§

impl<S> Send for BspGraph<S>
where IndexMap<usize, Box<dyn BspNode<S>>>: Send, Vec<Edge<S>>: Send, HashMap<String, Arc<dyn Fn(&S, &ValueStore) -> bool + Send + Sync>>: Send, HashMap<String, Arc<dyn Merger<S>>>: Send,

§

impl<S> Sync for BspGraph<S>
where IndexMap<usize, Box<dyn BspNode<S>>>: Sync, Vec<Edge<S>>: Sync, HashMap<String, Arc<dyn Fn(&S, &ValueStore) -> bool + Send + Sync>>: Sync, HashMap<String, Arc<dyn Merger<S>>>: Sync,

§

impl<S> Unpin for BspGraph<S>
where IndexMap<usize, Box<dyn BspNode<S>>>: Unpin, Vec<Edge<S>>: Unpin, HashMap<String, Arc<dyn Fn(&S, &ValueStore) -> bool + Send + Sync>>: Unpin, HashMap<String, Arc<dyn Merger<S>>>: Unpin,

§

impl<S> UnsafeUnpin for BspGraph<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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