Skip to main content

Ctx

Struct Ctx 

Source
pub struct Ctx { /* private fields */ }
Expand description

The single argument to a node fn. All emission is explicit via Ctx::down / Ctx::emit; there is no return-value framing (R-fn-contract / D8).

Implementations§

Source§

impl Ctx

Source

pub fn wave_data(&self) -> Vec<&[Vec<WaveData>]>

Raw dep-value input surface (R-ctx-wave-data / D77): dep -> waves -> values/SENTINEL.

Source

pub fn terminal(&self, i: usize) -> Option<&DepTerminal>

Terminal metadata for dep i, separate from wave_data (R-fn-contract / D77).

Source

pub fn dep_len(&self) -> usize

Number of declared deps in this fn invocation.

Source

pub fn deps_empty(&self) -> bool

True iff no deps are declared.

Source

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

Source

pub fn batches<U: 'static>(&self, i: usize) -> Vec<Vec<Rc<U>>>

Typed read of dep i’s accumulated DATA grouped by upstream wave.

Source

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.

Source

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.

Source

pub fn down(&self, msgs: Wave<AnyValue>)

Emit a raw wave downstream toward sinks (the ctx-level power surface, DR-1).

Source

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.

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

Source

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

Directed form of Ctx::up_next.

Source

pub fn state_get<S: 'static>(&self) -> Option<Rc<S>>

Read this node’s private cross-wave state (R-ctx-state / D23), typed.

Source

pub fn state_set<S: 'static>(&self, v: S)

Set this node’s private cross-wave state (R-ctx-state).

Source

pub fn state_persist(&self, on: bool)

Keep state across the fresh-lifecycle wipe (R-ctx-state / D29).

Source

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.

Source

pub fn on_deactivation(&self, f: impl FnOnce() + 'static)

Release external resources on deactivation (R-cleanup-hooks / D28). Fires once.

Source

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.

Source

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

Source

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

Source

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

Source

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

Auto Trait Implementations§

§

impl Freeze for Ctx

§

impl !RefUnwindSafe for Ctx

§

impl !Send for Ctx

§

impl !Sync for Ctx

§

impl Unpin for Ctx

§

impl UnsafeUnpin for Ctx

§

impl !UnwindSafe for Ctx

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