Skip to main content

WireSource

Trait WireSource 

Source
pub trait WireSource: Send + Sync {
    // Required methods
    fn get(&self, name: &str) -> Option<Value>;
    fn names(&self) -> Box<dyn Iterator<Item = String> + '_>;

    // Provided methods
    fn write(&self, _name: &str, _value: Value) -> WriteOutcome { ... }
    fn reset(&self, _name: &str) -> WriteOutcome { ... }
    fn advance(&self, _coord: u64) { ... }
}
Expand description

Cycle-time read surface a dispenser uses to resolve names from its bound Polydat context.

get(name) returns the current value of the named wire in the dispenser’s kernel. A None return indicates the name isn’t declared in this scope — callers MUST treat that as a resolution error, not a fallback opportunity (SRD-68 I-1).

names enumerates declared names for validators and describe_resolved-style introspection. Not for hot-path cycle reads; cycle reads use get.

Required Methods§

Source

fn get(&self, name: &str) -> Option<Value>

Look up name in this kernel’s scope. Returns the current value (cloned, owned) or None when the name is not declared here. Callers do not retry against another kernel — a None is the resolution result, full stop.

Source

fn names(&self) -> Box<dyn Iterator<Item = String> + '_>

Iterate declared names. Order is implementation-defined. Used by validators and diagnostic renderers.

Provided Methods§

Source

fn write(&self, _name: &str, _value: Value) -> WriteOutcome

Write value into the named input slot of this kernel. Returns WriteOutcome::Stored when the slot exists and the value was written, WriteOutcome::NoSlot when the kernel’s program has no input slot named name.

This is the canonical cycle-time capture path used by ResultDispenser and TraversingDispenser after their inner stack returns. Writes land on the kernel directly — no HashMap intermediary, no post-stack pump in the activity loop. Subsequent wires.get calls (e.g. from a later wrapper like MetricsDispenser) see fresh values.

Default impl returns NoSlot — appropriate for read-only implementations like NullWireSource and the bare &ScopeKernel baseline (which has no &mut handle to mutate state). CycleWires overrides with the real write path through the wrapped kernel’s set_input.

Source

fn reset(&self, _name: &str) -> WriteOutcome

Reset the named input slot to its DECLARED initial value — the author’s identity element for that wire. The capture layer uses this for min/max-of-nothing (SRD-93-era fold totality): an empty measurement restores the wire to its declared unit rather than parking Value::None on a typed slot, where every downstream consumer would have to be None-aware. Default impl returns NoSlot (read-only sources have nothing to reset).

Source

fn advance(&self, _coord: u64)

Advance the underlying kernel state to coordinate coord and invalidate any memoized pulls so subsequent get calls produce values for this coord.

Used by batch dispensers per the SRD-68 invariant:

“Within the batch view, each iteration of the batch is considered another pull, just as if the operation inside the batch were separate. It is simply an iteration container.”

The default impl is a no-op — NullWireSource and adapters that don’t drive batch iteration leave it alone. CycleWires overrides to mutate the wrapped kernel’s coord input. Calling advance on a WireSource that has no kernel handle (e.g. NullWireSource) is a no-op, not an error — the dispenser’s own wires.get calls will resolve correctly against whatever read surface the adapter has bound.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl WireSource for KernelWires<'_>

Source§

impl WireSource for NullWireSource

Source§

impl WireSource for ScopeKernel

WireSource over &ScopeKernel — covers names that the kernel’s lookup API already exposes (inputs, scope-init constants, shared-cell-backed values). Computed outputs that require a memoizing pull(&mut state, …) evaluation are NOT covered here and return None from get; the SRD-68 Push 2 work introduces a richer WireSource impl that owns the per-fiber kernel handle with interior mutability and can pull outputs at cycle time.

For Push 1 this &ScopeKernel impl is the additive baseline: every existing call site that gets handed a NullWireSource continues working unchanged, and code that wants kernel-side reads via the trait can use it for the names lookup already answers.

Source§

impl<'a> WireSource for CycleWires<'a>