pub struct Node<T> { /* private fields */ }Expand description
The typed facade over the erased substrate node (D5). Re-types the boundary:
cache()/set() downcast to T; deps are erased via Node::erased.
No PartialEq bound (D49: the substrate does no value-equality — dedup is
opt-in at the operator layer, e.g. distinctUntilChanged).
Implementations§
Source§impl<T: 'static> Node<T>
impl<T: 'static> Node<T>
Sourcepub fn state(initial: T) -> Node<T>
pub fn state(initial: T) -> Node<T>
A state node pre-populated with initial; a new subscriber gets [DATA]
(R-initial). Manual source — push new values with Node::set.
Sourcepub fn state_empty() -> Node<T>
pub fn state_empty() -> Node<T>
A SENTINEL state node — no value until the first Node::set.
Sourcepub fn producer<F: Fn(&Ctx) + 'static>(f: F) -> Node<T>
pub fn producer<F: Fn(&Ctx) + 'static>(f: F) -> Node<T>
A producer node (fn, no deps): runs once on activation, emits via ctx.emit.
Sourcepub fn producer_async<F: Fn(&Ctx) + 'static>(f: F) -> Node<T>
pub fn producer_async<F: Fn(&Ctx) + 'static>(f: F) -> Node<T>
A producer on the LocalAsync pool (D20): the fn runs once on activation and may
DEFER its emission — stash ctx.defer() and emit later via the DeferredCtx
(the async source pattern, R-sync-core / R-no-raw-async). Default pause mode
(true); a depless leaf source’s own production is delivered immediately even
while paused (R-pause-modes / C-10).
Sourcepub fn producer_opts<F: Fn(&Ctx) + 'static>(opts: NodeOpts, f: F) -> Node<T>
pub fn producer_opts<F: Fn(&Ctx) + 'static>(opts: NodeOpts, f: F) -> Node<T>
A producer with explicit NodeOpts (pool + pause mode).
Sourcepub fn derived<F: Fn(&Ctx) + 'static>(deps: Vec<Core>, f: F) -> Node<T>
pub fn derived<F: Fn(&Ctx) + 'static>(deps: Vec<Core>, f: F) -> Node<T>
A derived node over erased deps. The fn reads deps positionally via
ctx.data::<U>(i) and emits via ctx.emit. The first-run gate holds the fn
until every dep has settled (R-first-run-gate). A fn that returns WITHOUT
emitting (filter-reject) makes the substrate synthesize an undirty RESOLVED
(D49 / R-resolved-undirty).
Sourcepub fn derived_async<F: Fn(&Ctx) + 'static>(deps: Vec<Core>, f: F) -> Node<T>
pub fn derived_async<F: Fn(&Ctx) + 'static>(deps: Vec<Core>, f: F) -> Node<T>
A derived node on the LocalAsync pool (D20): the fn may DEFER its emission (stash
ctx.defer(), emit later). An async COMPUTE node (deps>0) that returns without
emitting has DEFERRED (not rejected) — no undirty RESOLVED is synthesized, and its
in-flight result buffers if the node is paused (R-async-paused / C-2/C-4). Default
pause mode (true).
Sourcepub fn derived_opts<F: Fn(&Ctx) + 'static>(
deps: Vec<Core>,
opts: NodeOpts,
f: F,
) -> Node<T>
pub fn derived_opts<F: Fn(&Ctx) + 'static>( deps: Vec<Core>, opts: NodeOpts, f: F, ) -> Node<T>
A derived node with explicit NodeOpts (pool + pause mode + dep-terminal policy).
Sourcepub fn set(&self, v: T)
pub fn set(&self, v: T)
Push a new value from a state node (one DATA wave). Always emits DATA — the substrate never absorbs to RESOLVED on value-equality (D49).
Sourcepub fn down(&self, msgs: Wave<AnyValue>)
pub fn down(&self, msgs: Wave<AnyValue>)
Emit a raw wave downstream (R-node-iface). The wave-owner boundary for the D30
catch (a panicking fn the cascade triggers becomes [[ERROR,e]], not an escape).
Sourcepub fn up(&self, msgs: Wave<AnyValue>)
pub fn up(&self, msgs: Wave<AnyValue>)
Emit a raw control wave upstream — control tiers only (R-ctx-up / R-node-iface). PAUSE/RESUME act on this node’s lockset (R-pause-lockset).
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 cache(&self) -> Option<T>where
T: Clone,
pub fn cache(&self) -> Option<T>where
T: Clone,
The current cached value (downcast), or None for SENTINEL.
Sourcepub fn version(&self) -> Option<NodeVersion>
pub fn version(&self) -> Option<NodeVersion>
Read-only node runtime version metadata (D109).
Sourcepub fn subscribe(
&self,
sink: impl Fn(&Message<AnyValue>) + 'static,
) -> Box<dyn FnOnce()>
pub fn subscribe( &self, sink: impl Fn(&Message<AnyValue>) + 'static, ) -> Box<dyn FnOnce()>
Subscribe a sink; returns an unsubscribe handle (call it to detach; the node deactivates when the last subscriber leaves, R-rom-ram).
This is also a wave-owner boundary: the activation cascade it drives runs under
the D30 catch, so a synchronous feedback cycle surfaces as [[ERROR,e]] on a
cycle node instead of escaping the subscribe call (C-6). Even on that error path
the returned handle is a REAL unsubscribe (the sink is registered before the
panicking activation, so the caller can always detach it).
Panics (R-terminal / D17): subscribing to a non-resubscribable terminal node is rejected — the stream is permanently over. (Resubscribable opt-in reset is a later slice.)
Sourcepub fn replace_deps<F: Fn(&Ctx) + 'static>(&self, new_deps: Vec<Core>, f: F)
pub fn replace_deps<F: Fn(&Ctx) + 'static>(&self, new_deps: Vec<Core>, f: F)
R-rewire (D42): replace this node’s deps atomically (surgical Option-C). Kept deps
keep their subscription + per-dep state; only removed deps unsubscribe + drain, only
added deps fresh-subscribe (push-on-subscribe for an added cached dep). The first-run
gate + cache are PRESERVED. Requires an explicit fn (SD-1 fn-deps pairing — user fns
read deps positionally). INTRA-graph only (D22). Deps are erased (Core).
Rejects (R-rewire): self-dep, a cycle, a terminal self, a (non-resubscribable)
terminal added dep, a reentrant rewire — these panic (propagate to the caller). A
mid-fn rewire (during this node’s own fn run) is the D37 feedback cycle → caught by
the running wave-owner as [[ERROR,e]], not a propagated panic.
Sourcepub fn subscribe_dep<F: Fn(&Ctx) + 'static>(&self, dep: Core, f: F) -> usize
pub fn subscribe_dep<F: Fn(&Ctx) + 'static>(&self, dep: Core, f: F) -> usize
Subscribe to one dep (special case of Node::replace_deps); returns its index. fn required (SD-1).
Sourcepub fn unsubscribe_dep<F: Fn(&Ctx) + 'static>(&self, dep: Core, f: F)
pub fn unsubscribe_dep<F: Fn(&Ctx) + 'static>(&self, dep: Core, f: F)
Unsubscribe from one dep (special case of Node::replace_deps); idempotent if absent (the fn
swap still applies). fn required (SD-1).