Skip to main content

Module derive_support

Module derive_support 

Source
Expand description

Trait surface that the #[polydat_node] proc-macro (polydat-derive) calls into for boxing / unboxing wire values.

§Canonical trait surface (SRD-80b)

  • Wire — Sized + 'static Rust-type ↔ Value bridge. Owned types only; the macro recognises borrow shapes (&str, &[u8], &[T], &serde_json::Value) syntactically and emits direct match-on-Value extraction at the eval call site — no trait dispatch, no unsafe lifetime transmute.

Combinator Wire impls cover Option<T> (None-aware pass-through) and Ext<T> (downcast through ReflectedValue).

A Const<T> position is not a Wire: the macro classifies it syntactically into a ConstShape and emits the extraction from the ConstArg inline, so there is no trait for it to dispatch through. A ConstSource trait once carried that, and stayed here after the macro stopped emitting calls to it.

§Why the trait surface lives here

polydat-derive is a proc-macro crate — it can’t define traits that are visible at the call site, only emit token streams referencing traits defined elsewhere. The macro emits <T as polydat::derive_support::Wire>::extract(...) paths; this module is what those paths resolve to.

Structs§

Config
Marker wrapper signalling that the wrapped wire is a configuration input — expensive to change because the node keeps internal state (LUTs, alias tables, parsed specs) derived from it. The macro emits the matching slot with Port::config() (SRD 15 §“WireCost::Config”) so the compiler warns on cycle-time binding.
Const
SRD-80 PR B.5 — marker wrapper for const arguments in #[polydat_node] function signatures.
DynamicOutputs
Marker wrapper for node return types whose output port COUNT is determined at construction time from a const-list arg’s length, not at codegen time. SRD-80b shape extension covering nodes like mixed_radix that emit one output per radix where radix count is a workload-supplied list.
Ext
Operator-side wrapper for adapter-typed wire arguments. Ext<T> signals “this arg comes from Value::Ext(Box<dyn ReflectedValue>); downcast it to T.” Implements Deref / DerefMut like Const<T> so the body can use .method() directly.
GroupResolver
Splice dataset_group_open(<source>) upstream when the wire source is a Str (SRD-53 DefaultResolver::Group).
Resolved
SRD-80b in-spirit replacement for the default_resolver attribute. The R parameter (a ResolverKind impl) carries the auto-resolver kind; the T parameter is the concrete Handle-inner type the body sees.

Traits§

PolydatSetup
SRD-80 PR B.6 — construction-time setup contract for nodes that derive a pre-computed runtime state from their const args (e.g. combinations parsing a charset pattern into segments + modulus, regex_match compiling a pattern, histribution parsing a distribution spec).
ResolverKind
Marker trait that names a kind of source-string auto-resolver for Resolved<R, T> wire args. The variants here mirror crate::dsl::registry::DefaultResolver; each impl picks one of them.
Wire
Rust-type ↔ Value bridge.

Functions§

buffer_for
An empty buffer with room for n elements, for a node whose buffer size comes from a value — a wire, a constant, or arithmetic on either.
read_poly
A polymorphic port’s slots as the owned Value the wire type names: a scalar from its bits, a Ref2 kind copied out of the pair its producer published.
ref_value
The value a Ref2 pair at the head of slots holds by reference: the one-element slice a JSON, extension, or handle producer published (jit_boundary.md, axiom S7: one dereference).
reserve_for
buffer_for for a buffer that is reused across evaluations: out is cleared and then has room for n elements. A native producer writing into step-owned scratch takes this shape, so its refusal reads the same as the node’s.
string_for
buffer_for for text: an empty String with room for n bytes.
try_buffer_for
buffer_for for a caller that reports failure as a value rather than as a node’s panic: a spec parser or a compile step, whose size comes from program text. The error is the same sentence.
write_poly
A polymorphic return written by the node’s resolved output type: a scalar as its bits into outputs[0], a Ref2 kind into scratch[0] with its pair republished (axiom S3). The value must be the port type’s carrier: the graph colored the slot by the node’s resolved output type, and a value of another type would be read by every consumer as something it is not, where the interpreter would have carried it. A None has no slot form on a compiled engine (engines.md §3.3).