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)

  • WireSized + '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.
  • ConstSourceSized + 'static typed-extraction from ConstArg for owned Const<T> positions.

Combinator Wire impls cover Option<T> (None-aware pass-through) and Ext<T> (downcast through ReflectedValue); ConstSource for Vec<C: ConstSource> handles workload-list constants.

§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(...) and <T as polydat::derive_support::ConstSource>::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<Vec<C>> 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§

ConstSource
ConstArg → typed-Rust-value bridge for owned types in Const<T> position.
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§

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).
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 of the port’s type: 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 (engine_parity.md, A12).