pub struct NodeContext {Show 25 fields
pub expanded_node: Weak<ExpandedNode>,
pub slot_index: LocalProperty<Option<usize>>,
pub expression_stack: Rc<RuntimePropertiesStackFrame>,
pub containing_component: Weak<ExpandedNode>,
pub elapsed_frames: LocalProperty<u64>,
pub elapsed_millis: LocalProperty<u64>,
pub gyro: LocalProperty<Gyro>,
pub accel: LocalProperty<Accel>,
pub bounds_parent: LocalProperty<(f64, f64)>,
pub bounds_self: LocalProperty<(f64, f64)>,
pub measured_size: LocalProperty<Option<(f64, f64)>>,
pub subtree_layout_hull: LocalProperty<LayoutHull>,
pub platform: Platform,
pub os: OS,
pub target: LocalProperty<TargetInfo>,
pub viewport: LocalProperty<Viewport>,
pub projected_children_count: LocalProperty<usize>,
pub node_transform_and_bounds: TransformAndBounds<NodeLocal, Window>,
pub projected_children: LocalProperty<Vec<Rc<ExpandedNode>>>,
pub projected_children_changed: LocalProperty<()>,
pub received_children: LocalProperty<Vec<Rc<ExpandedNode>>>,
pub received_children_count: LocalProperty<usize>,
pub received_children_changed: LocalProperty<()>,
pub retained_received_children: LocalProperty<Vec<Rc<ExpandedNode>>>,
pub retained_received_children_changed: LocalProperty<()>,
/* private fields */
}Expand description
This runtime owner stays on the UI thread. Transfer properties or delivery handles to workers instead.
fn requires_send<T: Send>() {}
requires_send::<pax_runtime::api::NodeContext>();Runtime context passed into user component lifecycle methods and event handlers.
For an inline binding, Rust self belongs to the component that authored
the binding, while this context describes the child receiving the call.
Bounds, expression stack access, subscriptions, and async lifetime remain target-local.
Component-level bindings receive their own component’s state and context.
Child-related fields intentionally separate semantic payload from engine transport:
projected_childrenis the raw transport family used bySlotreceived_childrenis the normalized semantic payload that this node should treat as content from its callerretained_received_childrenare former received children kept alive only so@outtransitions can finish
A node’s own private template or primitive-assembled structure is intentionally not surfaced here as a first-class “child family” for container consumers.
Fields§
§expanded_node: Weak<ExpandedNode>§slot_index: LocalProperty<Option<usize>>slot index of this node in its container
expression_stack: Rc<RuntimePropertiesStackFrame>§containing_component: Weak<ExpandedNode>Reference to the ExpandedNode of the component containing this node
elapsed_frames: LocalProperty<u64>The current global engine frame count.
elapsed_millis: LocalProperty<u64>The current global engine wall-clock time in milliseconds.
gyro: LocalProperty<Gyro>Current device orientation sensor reading.
accel: LocalProperty<Accel>Current device accelerometer reading.
bounds_parent: LocalProperty<(f64, f64)>The bounds of this element’s immediate container (parent) in px
bounds_self: LocalProperty<(f64, f64)>The bounds of this element in px
measured_size: LocalProperty<Option<(f64, f64)>>Measured bounds resolved by the chassis or container layout for this node.
subtree_layout_hull: LocalProperty<LayoutHull>Node-local subtree layout hull published by the engine for container measurement.
platform: PlatformCurrent platform (Web/Native) this app is running on
os: OSCurrent os (Android/Windows/Mac/Linux) this app is running on
target: LocalProperty<TargetInfo>Derived target facts for platform/OS checks.
viewport: LocalProperty<Viewport>Derived viewport facts for size and orientation checks.
projected_children_count: LocalProperty<usize>The number of projected children available to this node.
This is the raw transport count used by slot-driven implementations.
Container-style consumers usually want received_children_count
instead.
node_transform_and_bounds: TransformAndBounds<NodeLocal, Window>The transform of this node in the global coordinate space
projected_children: LocalProperty<Vec<Rc<ExpandedNode>>>Children projected into this node from the containing component.
Projection is an engine transport mechanism. Consumers that want the
semantic payload owned by this node should prefer received_children.
projected_children_changed: LocalProperty<()>A structural invalidation signal for projected children.
received_children: LocalProperty<Vec<Rc<ExpandedNode>>>Semantic payload children received by this node from its caller.
This is the canonical “content” view for container-style logic. It
excludes private encapsulated implementation children and also excludes
exit-retained payload nodes, which instead appear in
retained_received_children.
received_children_count: LocalProperty<usize>Convenience count derived from received_children.
received_children_changed: LocalProperty<()>A structural invalidation signal for received_children.
Prefer this or received_children itself for structural subscriptions
that must react to reorders as well as insertions and removals.
retained_received_children: LocalProperty<Vec<Rc<ExpandedNode>>>Received children retained only so exit transitions can finish.
These are no longer part of the active semantic payload, but some
containers still need to place them as ghosts or overlays while their
@out transitions run.
retained_received_children_changed: LocalProperty<()>A structural invalidation signal for retained_received_children.
Implementations§
Source§impl NodeContext
impl NodeContext
Sourcepub fn async_scope(&self) -> Result<AsyncScope, AsyncError>
pub fn async_scope(&self) -> Result<AsyncScope, AsyncError>
Lifetime of this exact context node, ending at actual unmount. Retain a component mount scope when later handlers receive child-control contexts. A saved context cannot acquire the scope of a later mount of that node.
Sourcepub fn application(&self) -> AppContext
pub fn application(&self) -> AppContext
Access the owning application lifetime, cancellation and error reporting.
Sourcepub fn local_point(&self, p: Point2<Window>) -> Point2<NodeLocal>
pub fn local_point(&self, p: Point2<Window>) -> Point2<NodeLocal>
Convert a window-space point into this node’s local coordinate space, including any presentation offsets inherited from ancestor scrollers.
Sourcepub fn get_node_interface(&self) -> Option<NodeInterface>
pub fn get_node_interface(&self) -> Option<NodeInterface>
Return the interface for this node’s containing component, when present.
Sourcepub fn elapsed_time_millis(&self) -> u128
pub fn elapsed_time_millis(&self) -> u128
Milliseconds elapsed according to the chassis-provided clock.
Sourcepub fn subscribe(
&self,
dependencies: &[UntypedProperty],
f: impl Fn() + 'static,
)
pub fn subscribe( &self, dependencies: &[UntypedProperty], f: impl Fn() + 'static, )
Attach a dependency subscription whose callback runs when any dependency dirties.
Sourcepub fn clear_subscriptions(&self)
pub fn clear_subscriptions(&self)
Remove all subscriptions registered on this node.
Ask the chassis to navigate to a URL.
On web targets, same-origin navigation in the current tab can be handled
through the browser History API and routed back into Pax without a full
page reload. Cargo metadata’s
[package.metadata.pax.web].server_owned_prefixes delegates matching paths
to ordinary browser navigation before changing application history.
Other targets use the active chassis navigation behavior.
Sourcepub fn dispatch_event(&self, identifier: &'static str) -> Result<(), String>
pub fn dispatch_event(&self, identifier: &'static str) -> Result<(), String>
Queue a named custom event from this component for dispatch at the end of the tick.
Sourcepub fn set_cursor(&self, cursor: CursorStyle)
pub fn set_cursor(&self, cursor: CursorStyle)
Ask the chassis to display the requested cursor over the app surface.
Sourcepub fn screenshot(&self, id: u32)
pub fn screenshot(&self, id: u32)
Request a screenshot capture from the chassis, keyed by caller-provided id.
Sourcepub fn get_screenshot_map(&self) -> Rc<RefCell<HashMap<u32, ScreenshotData>>>
pub fn get_screenshot_map(&self) -> Rc<RefCell<HashMap<u32, ScreenshotData>>>
Shared map where completed screenshot captures are published by id.
Source§impl NodeContext
impl NodeContext
Sourcepub fn provide_store<T: Store>(&self, store: T) -> Result<(), StoreError>
pub fn provide_store<T: Store>(&self, store: T) -> Result<(), StoreError>
Publish a store on this context’s mounted node, keyed by its concrete Rust type.
Register in the component’s own mount handler to give each component
instance an independent provider. In an inline descendant handler, the
context identifies that descendant even when Rust self is its authoring
component. The context’s node, not self, owns the registration.
The owner and its logical descendants can find the value with with_store.
This includes private template children and caller-supplied children;
private wrappers around a slot do not change projected content’s ancestry.
Siblings and ancestors cannot discover this registration.
Providing the same type again on the same owner replaces its entry for future lookups. Previously cloned handles keep their original state; the registry is not reactive. Prefer updating properties in a stable store. Providers are cleared at final unmount, after unmount handlers run.
Returns StoreError::ExpiredScope for an unmounted or stale context, or
StoreError::BorrowConflict if the entry being replaced is borrowed.
Sourcepub fn with_store<T: Store, V>(
&self,
f: impl FnOnce(&mut T) -> V,
) -> Result<V, StoreError>
pub fn with_store<T: Store, V>( &self, f: impl FnOnce(&mut T) -> V, ) -> Result<V, StoreError>
Borrow the nearest provider of T, starting with this context’s node.
Lookup follows logical template ancestry, independently of expression scope and render parents. A nearer same-type provider shadows an outer one; unrelated types remain visible. It never searches siblings or descendants. Two consumers share state when they resolve the same provider.
The closure exclusively borrows that store for its duration. Clone a
needed Property handle inside the closure, then read or update it after
the borrow ends. This avoids conflicts if subsequent work looks up the
same store. The returned value can be a handle or an owned snapshot, but
cannot borrow from the store.
Returns StoreError::Missing when no provider exists,
StoreError::ExpiredScope when the context or an ancestor’s mount has
ended, and StoreError::BorrowConflict when the nearest provider is
already borrowed. A conflict or expired scope never falls back to an
outer provider. Saved contexts cannot discover a later mount’s stores.