Expand description
polydat-derive — proc-macro implementation of
#[polydat_node].
The attribute turns a typed free function into a polydat node.
From one fn it emits the node struct (named after the function
in PascalCase), its new() constructor, the PolydatNode impl
(meta, eval, and the compiled forms the signature allows),
and a link-time NodeRegistration carrying the FuncSig the
DSL registry serves. The function’s /// comment becomes the
struct’s documentation and the signature’s description (first
paragraph) and help (the rest).
§Arguments
Each argument is classified by its type and attributes:
- Wire — a per-cycle input. Scalars (
u64,i64,f64,bool, the narrower ints,f32,f16,u128,i128), strings (&str,String,Arc<str>), bytes (&[u8],Vec<u8>,Arc<[u8]>), JSON (&serde_json::Value,Arc<serde_json::Value>), typed vectors (&[f32],Vec<i64>, …), SIMD registers (Bits128,[i32; 4], …),Arc<T>handles, and hostExttypes.Option<T>marks an input that may be unset;Config<T>marks a configuration-cost wire.#[constraint(Variant)]attaches aConstConstraintto a wire input. - PolyWire — a
Valueargument: any runtime type; the output type of aValuereturn tracks the first PolyWire input. - Variadic — a
&[T]argument forTinu64,bool,&str,String,Value; two consecutive slices form a split-halves shape.variadic_minandidentitydescribe the arity. - Const —
Const<u64 | f64 | bool | &str>, a workload constant captured at construction;#[poly_default(EXPR)]supplies its default.Const<Vec<C>>(last) captures every trailing constant of the call. - Setup — a
&Targument with#[poly_const(setup_fn, from = source)]: derived state computed once innew()from the named const arguments (from = ()for none,from = (a, b)for several).TimplementsPolydatSetup.
§Returns
A single wire type; a tuple of wire types (multi-output, named
by output_names(...)); Value (polymorphic); Result<T, E>
for a body that runs once at construction and caches its value;
or a dynamic-output list over a Const<Vec<C>> argument.
§Attribute parameters
category = <FuncCategory>— required.struct_name = <Ident>— the Rust name of the node struct.compiled_u64 = <path>—fn(&Node) -> CompiledU64Op, replacing the macro’s u64-buffer closure.compiled_handle = <path>—fn(&Node, usize, &[PortType]) -> CompiledU64Op, replacing the handle-kit closure.jit_constants = <path>—fn(&Node) -> Vec<u64>.decompose = <path>—fn(&Node) -> DecomposedGraph, emittingimpl FusedNode.simd = "<node>",simd_total— an exact register-typed implementation of the scalar function.purity = <Purity>,identity = <expr>,commutativity = <Commutativity>,variadic_min = <int>.output_names(a, b, ...)— the ports of a tuple return.
Attribute Macros§
- polydat_
node #[polydat_node]— derive a polydat node from a typed Rust function signature.