#[non_exhaustive]pub struct FuncSig {Show 13 fields
pub name: &'static str,
pub category: FuncCategory,
pub outputs: usize,
pub description: &'static str,
pub help: &'static str,
pub identity: Option<u64>,
pub variadic_ctor: Option<fn(usize) -> Box<dyn PolydatNode>>,
pub params: &'static [ParamSpec],
pub arity: Arity,
pub commutativity: Commutativity,
pub default_resolver: Option<DefaultResolver>,
pub output_type: OutputType,
pub output_port: Option<PortType>,
}Expand description
Description of a registered function’s signature.
A signature is built with FuncSig::new and the with_ methods,
all const, so a module’s signatures can live in a static:
use polydat_core::ast::{PortType, SlotType};
use polydat_core::dsl::registry::{FuncCategory, FuncSig, ParamSpec};
static SIGS: &[FuncSig] = &[FuncSig::new(
"counted_mod",
FuncCategory::Arithmetic,
&[ParamSpec::wire("x"), ParamSpec::new("m", SlotType::ConstU64).with_example("7")],
)
.with_description("mod, built by a host factory")
.with_output_port(PortType::U64)];The struct is #[non_exhaustive]: a field added later is not a
breaking change to a host that builds one, since the new field
arrives with its default.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: &'static strFunction name as used in the DSL.
category: FuncCategoryFunctional category.
outputs: usizeNumber of output ports (0 = dynamic, determined at compile time).
description: &'static strShort description for help/error messages.
help: &'static strDetailed help text: theory, usage examples, parameter meanings. Long-form help text for listings and documentation.
identity: Option<u64>For variadic functions: the identity element for zero inputs.
variadic_ctor: Option<fn(usize) -> Box<dyn PolydatNode>>Factory for variadic nodes: takes wire count, returns node.
params: &'static [ParamSpec]Positional parameter list: wires and constants in call order.
arity: ArityArity specification.
commutativity: CommutativityInput commutativity for this function.
default_resolver: Option<DefaultResolver>Optional resolver hint for Handle-typed input ports. When
the binding compiler emits this function and a Handle
input is wired to a Str-producing source, it splices in
the named resolver to convert the string into a handle. This
is the “string-conversion node insertion” mechanism of
source-string call-site sugar. None means no
auto-promotion — the caller must pass a Handle directly.
output_type: OutputTypeOutput-type contract — Fixed for the vast majority of
nodes; SameAsInput(idx) for type-polymorphic pass-throughs
(e.g. log_info whose output type tracks its sole input).
output_port: Option<PortType>Concrete port type of the single output, when statically
known (#[polydat_node] emits it from the return type’s
Wire::PORT). None for tuple/dynamic/polymorphic outputs
and for hand registrations that don’t declare one. The DSL
type inference (binding::infer_expr_type) reads this
FIRST — the name-prefix heuristic is only the fallback —
so call-expression operand typing flows from the symbol
registry, not from a hand-maintained list.
Implementations§
Source§impl FuncSig
impl FuncSig
Sourcepub const fn new(
name: &'static str,
category: FuncCategory,
params: &'static [ParamSpec],
) -> Self
pub const fn new( name: &'static str, category: FuncCategory, params: &'static [ParamSpec], ) -> Self
The signature of name in category taking params: one
output of a fixed type not stated here, a fixed arity, positional
inputs, no description or help, and none of the optional parts.
The with_ methods change each of these.
Sourcepub const fn with_outputs(self, outputs: usize) -> Self
pub const fn with_outputs(self, outputs: usize) -> Self
The signature with outputs output ports (0 for a count fixed at
compile time).
Sourcepub const fn with_description(self, description: &'static str) -> Self
pub const fn with_description(self, description: &'static str) -> Self
The signature with the short description description.
Sourcepub const fn with_help(self, help: &'static str) -> Self
pub const fn with_help(self, help: &'static str) -> Self
The signature with the long-form help text help.
Sourcepub const fn with_identity(self, identity: u64) -> Self
pub const fn with_identity(self, identity: u64) -> Self
The signature of a variadic function whose identity element, for
zero inputs, is identity.
Sourcepub const fn with_variadic_ctor(
self,
ctor: fn(usize) -> Box<dyn PolydatNode>,
) -> Self
pub const fn with_variadic_ctor( self, ctor: fn(usize) -> Box<dyn PolydatNode>, ) -> Self
The signature of a variadic function whose node for a given
wire count ctor builds.
Sourcepub const fn with_arity(self, arity: Arity) -> Self
pub const fn with_arity(self, arity: Arity) -> Self
The signature with the arity arity.
Sourcepub const fn with_commutativity(self, commutativity: Commutativity) -> Self
pub const fn with_commutativity(self, commutativity: Commutativity) -> Self
The signature with the input commutativity commutativity.
Sourcepub const fn with_default_resolver(self, resolver: DefaultResolver) -> Self
pub const fn with_default_resolver(self, resolver: DefaultResolver) -> Self
The signature whose Handle inputs, wired from a Str, are
resolved by resolver.
Sourcepub const fn with_output_type(self, output_type: OutputType) -> Self
pub const fn with_output_type(self, output_type: OutputType) -> Self
The signature with the output-type contract output_type.
Sourcepub const fn with_output_port(self, port: PortType) -> Self
pub const fn with_output_port(self, port: PortType) -> Self
The signature whose single output has the port type port.
Sourcepub fn wire_input_count(&self) -> usize
pub fn wire_input_count(&self) -> usize
Number of wire inputs in the fixed parameter list.
Sourcepub fn is_variadic(&self) -> bool
pub fn is_variadic(&self) -> bool
Whether this function accepts variadic arguments.
Sourcepub fn const_param_info(&self) -> Vec<(&'static str, bool)>
pub fn const_param_info(&self) -> Vec<(&'static str, bool)>
Constant parameter names and whether they’re required.
Trait Implementations§
Auto Trait Implementations§
impl Forget for FuncSig
impl Freeze for FuncSig
impl Move for FuncSig
impl RefUnwindSafe for FuncSig
impl Send for FuncSig
impl Sync for FuncSig
impl Unpin for FuncSig
impl UnsafeUnpin for FuncSig
impl UnwindSafe for FuncSig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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