Skip to main content

Node

Struct Node 

Source
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>

Source

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.

Source

pub fn state_empty() -> Node<T>

A SENTINEL state node — no value until the first Node::set.

Source

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.

Source

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).

Source

pub fn producer_opts<F: Fn(&Ctx) + 'static>(opts: NodeOpts, f: F) -> Node<T>

A producer with explicit NodeOpts (pool + pause mode).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

pub fn up_toward(&self, toward_dep: usize, msgs: Wave<AnyValue>)

Directed upstream control along one declared dep edge (R-up-routing).

Source

pub fn cache(&self) -> Option<T>
where T: Clone,

The current cached value (downcast), or None for SENTINEL.

Source

pub fn status(&self) -> Status

The node’s lifecycle status (R-status-enum).

Source

pub fn version(&self) -> Option<NodeVersion>

Read-only node runtime version metadata (D109).

Source

pub fn pull_id(&self) -> Option<LockId>

Updates or reads pull_id.

Source

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.)

Source

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.

Source

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).

Source

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).

Source

pub fn erased(&self) -> Core

The erased core, for wiring this node as a dep of a derived node.

Trait Implementations§

Source§

impl<T> Clone for Node<T>

A cheap handle clone — both Nodes address the SAME underlying node (the shared Rc<RefCell<…>>), like cloning a Core. Manual (not #[derive]) so it does NOT require T: Clone — the value type need not be cloneable for the handle to be.

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Node<T>

§

impl<T> !RefUnwindSafe for Node<T>

§

impl<T> !Send for Node<T>

§

impl<T> !Sync for Node<T>

§

impl<T> Unpin for Node<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Node<T>

§

impl<T> !UnwindSafe for Node<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,