Skip to main content

Module wires

Module wires 

Source
Expand description

WireSource — narrow read trait for op-template name resolution.

SRD-68 §“The narrow trait” specifies the wall between adapter code and crate::scope_kernel::ScopeKernel internals: a dispenser at cycle time accesses its bound Polydat context only through this trait’s get (value lookup by name) and names (declared-name iteration for diagnostics). No program(), no state(), no scope_coordinates() — adapter code is sealed off from kernel mechanics.

Two implementations ship here:

  • ScopeKernel itself, via the kernel’s existing lookup chain (input slots, outputs, inherited scope state). Single resolution surface — name resolves where SRD-67 places it, no fallback (SRD-68 invariant I-1).
  • NullWireSource, a unit type that returns None for every name. Used as the default value in ExecCtx::new during the SRD-68 migration so call sites that don’t yet have a kernel handle don’t break — adapters opt in via ExecCtx::with_wires once they own a kernel reference.

See docs/SRD/68_dispenser_owned_polydat_context.md.

Structs§

CycleWires
WireSource over a per-fiber kernel handle that supports the full read surface — inputs, scope-init constants, AND computed outputs (which need a memoizing pull(&mut state, …) to fire the eval cone). Wraps a &mut ScopeKernel in a Mutex so the trait stays &self-callable (and Sync) while still permitting pull’s &mut requirement.
KernelWires
Read-only WireSource over a kernel of any engine: the names a scope lookup answers (KernelLookup — a const’s value, an input, a folded value), as the ScopeKernel impl below does for the interpreter. Computed outputs that need a pull are not covered; CycleWires is the surface that pulls. What an adapter’s canonical kernel offers a wrap-time reader.
NullWireSource
Empty WireSource — every get returns None, names is empty. Used as the default for ExecCtx::new so callers that don’t yet have a kernel handle don’t need to construct a real implementation. Migration call sites switch to ExecCtx::with_wires when they own a kernel reference (see SRD-68 Push 2 and beyond).

Enums§

HostWriteError
Why a write_input did not land.
WriteOutcome
Result of a WireSource::write call.

Statics§

NULL_WIRES
Static &'static dyn WireSource for use as the default in ExecCtx::new. Avoids per-call allocation; the unit struct has no state to differ.

Traits§

ProgramKernel
A kernel that carries the interpreter program its names resolve on: a scope kernel, or an interpreter kernel.
WireSource
Cycle-time read surface a dispenser uses to resolve names from its bound Polydat context.

Functions§

resolve_op_fields_via_wires
Resolve a list of op-template field entries through the generic wires API. Each entry is (field_name, json_value_from_template); the helper returns name+value pairs an adapter can hand to its renderer, with no synthesis-layer involvement.
substitute_via_wires
Render template by substituting each {name} placeholder with wires.get(name)’s display-string form. The single resolution-via-wires entry point adapters use at cycle time per SRD-68 Push 5 — replaces the synthesis-layer substitute_bind_points* text-mutation pass.
write_input
nmbrs’s one rule for writing a host value into a kernel input.