Skip to main content

Module const_constraints

Module const_constraints 

Source
Expand description

Assembly-time validation of Polydat node constant arguments.

Polydat’s contract (SRD 15 §“Input Validity Model”) keeps the hot path branch-free by letting node ::new trust its constants — no runtime checks. That only holds if the factory has already proven each constant satisfies the node’s contract, rejecting violations with a structured compile error before the node is constructed.

This module provides the vocabulary for those checks:

  • ConstConstraint describes a single constraint on one constant argument. Apply it with ConstConstraint::check.
  • NodeValidator is the per-module function the factory calls before build. It gets the function name and the resolved constant args and returns Ok(()) or a structured error string.

A module opts in by passing a validator as the third argument to register_nodes!. Modules that don’t need validation omit it and the factory skips the check.

Enums§

ConstConstraint
A declarative constraint on one constant argument of a node call.

Functions§

check_opt
Convenience: apply a single constraint to an optional positional argument. Absence is treated as “no value to check” (Ok) — the required flag on ParamSpec already handles mandatory-ness.

Type Aliases§

NodeValidator
Per-module validator the factory calls before build_node.