pub struct GraphBuilder { /* private fields */ }Expand description
Builder for a single Limen graph AST (ast::GraphDef).
GraphBuilder collects nodes and edges with precise typing, so you get full
IDE completion and compiler checking while authoring graphs in build.rs.
Implementations§
Source§impl GraphBuilder
impl GraphBuilder
Sourcepub fn new(name: &str, vis: GraphVisibility) -> Self
pub fn new(name: &str, vis: GraphVisibility) -> Self
Create a new graph builder.
§Parameters
name: graph type name as an identifier string (e.g."MyGraph").vis: aGraphVisibilityenum controllingpub/pub(crate)/pub(super)/ private.
This convenience avoids calling syn::parse_quote in build.rs; we
synthesize a syn::Visibility internally.
Sourcepub fn node(self, n: Node) -> Self
pub fn node(self, n: Node) -> Self
Append a fully specified node to the graph.
The Node parameter is a fluent sub-builder; it is converted to an
ast::NodeDef at call time.
§Examples
use limen_codegen::builder::{GraphBuilder, GraphVisibility, Node};
let gb = GraphBuilder::new("MyGraph", GraphVisibility::Public)
.node(
Node::new(0)
.ty::<MySource>()
.in_ports(0)
.out_ports(1)
.in_payload::<()>()
.out_payload::<u32>()
);Sourcepub fn node_from_link<N, const IN: usize, const OUT: usize, InP, OutP>(
self,
link: NodeLink<N, IN, OUT, InP, OutP>,
ingress_policy: Option<EdgePolicy>,
) -> Self
pub fn node_from_link<N, const IN: usize, const OUT: usize, InP, OutP>( self, link: NodeLink<N, IN, OUT, InP, OutP>, ingress_policy: Option<EdgePolicy>, ) -> Self
Append a Node described by a core NodeLink — the builder extracts
its type, payload types, id, and optional name and constructs an AST
ast::NodeDef entry.
ingress_policy is optional; supply it for source nodes.
Sourcepub fn edge(self, e: Edge) -> Self
pub fn edge(self, e: Edge) -> Self
Append a fully specified edge to the graph.
The Edge parameter is a fluent sub-builder; it is converted to an
ast::EdgeDef at call time.
§Examples
use limen_codegen::builder::{GraphBuilder, GraphVisibility, Edge};
use limen_core::policy::{AdmissionPolicy, EdgePolicy, OverBudgetAction, QueueCaps};
let policy = EdgePolicy::new(
QueueCaps::new(8, 6, None, None),
AdmissionPolicy::DropNewest,
OverBudgetAction::Drop,
);
let gb = GraphBuilder::new("MyGraph", GraphVisibility::Public)
.edge(
Edge::new(0)
.ty::<limen_core::edge::spsc_array::StaticRing<8>>()
.payload::<u32>()
.manager_ty::<limen_core::memory::static_manager::StaticMemoryManager<u32, 8>>()
.from(0, 0)
.to(1, 0)
.policy(policy)
.name(Some("source->map"))
);Sourcepub fn edge_from_link<Q, P, M>(self, link: EdgeLink<Q>) -> Self
pub fn edge_from_link<Q, P, M>(self, link: EdgeLink<Q>) -> Self
Append an Edge described by a core EdgeLink. The builder extracts the
queue type, endpoints, policy, and id and converts them into an
ast::EdgeDef.
The payload type P and memory manager type M must be supplied
explicitly because EdgeLink does not carry them.
Sourcepub fn concurrent(self, emit_concurrent: bool) -> Self
pub fn concurrent(self, emit_concurrent: bool) -> Self
Control whether to emit the std-only scoped execution API
(ScopedGraphApi) for the generated graph.
This does not change the graph structure. It only controls whether
codegen emits the extra run_scoped(..) implementation.
Sourcepub fn to_graph_def(self) -> GraphDef
pub fn to_graph_def(self) -> GraphDef
Finalize and produce the ast::GraphDef.
This consumes the builder and returns a complete graph AST suitable for code generation.
§Panics
Panics if the builder was not created via GraphBuilder::new, or if
vis or name were not set.
Sourcepub fn finish(self) -> GraphWriter
pub fn finish(self) -> GraphWriter
Finalize and produce a GeneratedGraph that owns the AST and can write it to file.