pub struct NodeRegistration {
pub signatures: fn() -> &'static [FuncSig],
pub build: NodeBuildFn,
pub validate: Option<NodeValidator>,
}Expand description
A node module’s registration: signatures + builder.
Each node module submits one of these at link time via inventory::submit!.
The runtime collects all submissions to build the function registry and
dispatch table without any explicit module list.
A registration is a NodeFactory: its build is the factory’s
body, and the registry builds its nodes through that factory as it
builds every other node (crate::dsl::factory::build_node).
Fields§
§signatures: fn() -> &'static [FuncSig]Returns the static slice of FuncSig entries for this module.
build: NodeBuildFnBuilds a node for the given function name: the body of this
registration’s NodeFactory::build.
Returns Some(Ok(node)) / Some(Err(msg)) for a name it
builds, and None for one it leaves to its signature: a
variadic function then gets its signature’s identity element or
variadic constructor, and any other name is an unknown function.
wire_types[i] is the resolved crate::ast::PortType of
wires[i] — the output type of the upstream node feeding
that wire input. Modules that build type-polymorphic nodes
(e.g. log_info, whose output type equals its input type)
read this to construct the node with the correct port
types. Modules whose nodes have type-fixed signatures can
ignore the slice. When the assembler can’t resolve a
wire’s type (forward reference, dangling), the slot
defaults to crate::ast::PortType::U64.
validate: Option<NodeValidator>Optional assembly-time validator for this module’s constants.
The factory calls this before build whenever the name
matches one of this module’s functions. Returning Err makes
the compile fail with a structured bad constant error, so
the node itself never sees a malformed literal and can keep
its constructor and eval() branch-free.
Trait Implementations§
impl Collect for NodeRegistration
Source§impl NodeFactory for NodeRegistration
impl NodeFactory for NodeRegistration
Source§fn build(
&self,
ctx: &BuildContext,
name: &str,
wires: &[WireRef],
wire_types: &[PortType],
consts: &[ConstArg],
) -> Result<Box<dyn PolydatNode>, String>
fn build( &self, ctx: &BuildContext, name: &str, wires: &[WireRef], wire_types: &[PortType], consts: &[ConstArg], ) -> Result<Box<dyn PolydatNode>, String>
The registered builder’s node. A builder that declines a name its signatures list leaves a variadic function to its signature: the identity element for no wires, the variadic constructor otherwise.
Source§fn signatures(&self) -> &[FuncSig]
fn signatures(&self) -> &[FuncSig]
Source§fn validate(&self, name: &str, consts: &[ConstArg]) -> Result<(), String>
fn validate(&self, name: &str, consts: &[ConstArg]) -> Result<(), String>
Self::build; an
Err fails the compile as a bad constant, so build never sees
a malformed literal. The registry has already applied each
parameter’s declared ConstConstraint. Accepts everything
unless overridden.Auto Trait Implementations§
impl Freeze for NodeRegistration
impl RefUnwindSafe for NodeRegistration
impl Send for NodeRegistration
impl Sync for NodeRegistration
impl Unpin for NodeRegistration
impl UnsafeUnpin for NodeRegistration
impl UnwindSafe for NodeRegistration
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more