pub struct Ctx { /* private fields */ }Expand description
Implementations§
Source§impl Ctx
impl Ctx
Sourcepub fn wave_data(&self) -> Vec<&[Vec<WaveData>]>
pub fn wave_data(&self) -> Vec<&[Vec<WaveData>]>
Raw dep-value input surface (R-ctx-wave-data / D77): dep -> waves -> values/SENTINEL.
Sourcepub fn terminal(&self, i: usize) -> Option<&DepTerminal>
pub fn terminal(&self, i: usize) -> Option<&DepTerminal>
Terminal metadata for dep i, separate from wave_data (R-fn-contract / D77).
Sourcepub fn deps_empty(&self) -> bool
pub fn deps_empty(&self) -> bool
True iff no deps are declared.
Sourcepub fn data<U: 'static>(&self, i: usize) -> Option<Rc<U>>
pub fn data<U: 'static>(&self, i: usize) -> Option<Rc<U>>
Typed read of dep i’s latest DATA, downcast to U (SENTINEL → None).
Returns Rc<U> (shared, no value clone). Data flows through messages —
this reads the wave snapshot, never peeks the dep’s .cache (R-data-not-peek).
Sourcepub fn batches<U: 'static>(&self, i: usize) -> Vec<Vec<Rc<U>>>
pub fn batches<U: 'static>(&self, i: usize) -> Vec<Vec<Rc<U>>>
Typed read of dep i’s accumulated DATA grouped by upstream wave.
Sourcepub fn batch<U: 'static>(&self, i: usize) -> Vec<Rc<U>>
pub fn batch<U: 'static>(&self, i: usize) -> Vec<Rc<U>>
Typed DATA payloads dep i delivered in this invocation, flattened across
upstream waves. This is a derived helper; raw occurrence shape lives in wave_data.
Sourcepub fn emit<T: 'static>(&self, v: T)
pub fn emit<T: 'static>(&self, v: T)
Emit one typed DATA downstream — the value-level sugar (R-primary-api-clean): the protocol DIRTY-before-DATA framing is synthesized by the substrate.
Sourcepub fn down(&self, msgs: Wave<AnyValue>)
pub fn down(&self, msgs: Wave<AnyValue>)
Emit a raw wave downstream toward sinks (the ctx-level power surface, DR-1).
Sourcepub fn up(&self, msgs: Wave<AnyValue>)
pub fn up(&self, msgs: Wave<AnyValue>)
Emit upstream toward deps — control tiers only (R-ctx-up). Validates the kind; the terminus actions (PAUSE lockset / INVALIDATE honor) are deferred.
Sourcepub fn up_toward(&self, toward_dep: usize, msgs: Wave<AnyValue>)
pub fn up_toward(&self, toward_dep: usize, msgs: Wave<AnyValue>)
Directed upstream control along one declared dep edge (R-up-routing).
Sourcepub fn up_next(&self, msgs: Wave<AnyValue>)
pub fn up_next(&self, msgs: Wave<AnyValue>)
Defer an upstream control wave to the committed wave boundary (R-rewire-deferred).
This is the self-demand path for pull nodes: PULL({pullId, params?}) routes
after the current fn settles, avoiding D37 mid-wave re-entry.
Sourcepub fn up_next_toward(&self, toward_dep: usize, msgs: Wave<AnyValue>)
pub fn up_next_toward(&self, toward_dep: usize, msgs: Wave<AnyValue>)
Directed form of Ctx::up_next.
Sourcepub fn state_get<S: 'static>(&self) -> Option<Rc<S>>
pub fn state_get<S: 'static>(&self) -> Option<Rc<S>>
Read this node’s private cross-wave state (R-ctx-state / D23), typed.
Sourcepub fn state_set<S: 'static>(&self, v: S)
pub fn state_set<S: 'static>(&self, v: S)
Set this node’s private cross-wave state (R-ctx-state).
Sourcepub fn state_persist(&self, on: bool)
pub fn state_persist(&self, on: bool)
Keep state across the fresh-lifecycle wipe (R-ctx-state / D29).
Sourcepub fn pull(&self) -> Option<&PullDemand>
pub fn pull(&self) -> Option<&PullDemand>
Holder-visible context for a PULL-caused invocation (D272). Absent for normal dep-settle, activation, pause replay, terminal, and non-pull runs.
Sourcepub fn on_deactivation(&self, f: impl FnOnce() + 'static)
pub fn on_deactivation(&self, f: impl FnOnce() + 'static)
Release external resources on deactivation (R-cleanup-hooks / D28). Fires once.
Sourcepub fn on_invalidate(&self, f: impl Fn() + 'static)
pub fn on_invalidate(&self, f: impl Fn() + 'static)
Flush external state on INVALIDATE (R-cleanup-hooks / D28). Re-callable: fires
once per INVALIDATE wave. INVALIDATE is lifecycle-continue (R-ctx-state / D29) —
it does NOT wipe ctx.state, so any internal reset must be done here.
Sourcepub fn rewire_next_subscribe_dep<F: Fn(&Ctx) + 'static>(&self, dep: Core, f: F)
pub fn rewire_next_subscribe_dep<F: Fn(&Ctx) + 'static>(&self, dep: Core, f: F)
Request a deferred self-rewire subscribe at the committed wave boundary (R-rewire-deferred /
D47): subscribe to dep (and swap the fn) AFTER the current wave settles — never in place, so
this is NOT the D37 mid-fn reject. Higher-order operators (*Map) use this to wire
runtime-created inner nodes as VISIBLE self-deps. f re-pairs the deps (SD-1 pairing).
Sourcepub fn rewire_next_unsubscribe_dep<F: Fn(&Ctx) + 'static>(
&self,
dep: Core,
f: F,
)
pub fn rewire_next_unsubscribe_dep<F: Fn(&Ctx) + 'static>( &self, dep: Core, f: F, )
Request a deferred self-rewire unsubscribe (R-rewire-deferred): if dep is still live at the
boundary, unsubscribe from it + swap the fn. If the identity is already absent at apply time, the
request is a full no-op, including no fn swap, so stale duplicate unsubscribes cannot desync
the live dep/fn pairing. A successful unsubscribe DRAINS the dep’s edge + tears down its source
on last-subscriber (onDeactivation) = the switchMap/abortInFlight cancellation + memory
bounding (D47 beta).
Sourcepub fn rewire_next_replace_deps<F: Fn(&Ctx) + 'static>(
&self,
deps: Vec<Core>,
f: F,
)
pub fn rewire_next_replace_deps<F: Fn(&Ctx) + 'static>( &self, deps: Vec<Core>, f: F, )
Request a deferred self-rewire replace (R-rewire-deferred): replace the whole dep set + swap the fn at the boundary (the switch-variant — removes-before-adds keeps the tracked inner list aligned across boundary waves).
Sourcepub fn defer(&self) -> DeferredCtx
pub fn defer(&self) -> DeferredCtx
Obtain an owned, 'static deferred-emit handle for async-pool late emission
(R-sync-core / R-no-raw-async: async lives in the fn body; the emit serializes
back onto the single thread). The Rust analogue of the TS async fn capturing its
ctx — here &Ctx is a borrow that cannot outlive invoke, so an async fn must
stash this owned handle and call DeferredCtx::emit / DeferredCtx::down
later. Carries the wave’s dep snapshot so a deferred read sees this wave’s view
(matches the TS per-invocation async ctx snapshot).