pub struct Scope(/* private fields */);Expand description
A UI context carries semantic parent identity, never a DOM/GPU object. Core ownership remains separate; all presentation helpers work on any Render.
Implementations§
Source§impl Scope
impl Scope
pub fn instantiate(&self, plan: &Plan) -> Result<PlanInstance>
pub fn mount_with<W: Widget>( &self, factory: impl FnOnce() -> W, ) -> Result<Mounted>
Sourcepub fn downgrade(&self) -> WeakScope
pub fn downgrade(&self) -> WeakScope
A callback may upgrade transiently without retaining its owning UI scope.
Sourcepub fn batch<R>(&self, callback: impl FnOnce() -> R) -> Result<R>
pub fn batch<R>(&self, callback: impl FnOnce() -> R) -> Result<R>
Apply several writes as one observation boundary. Nested calls remain atomic and unwind releases the boundary. Host output still commits at the App’s normal flush/event boundary.
pub fn child(&self) -> Result<Self>
pub fn child_in(&self, parent: NodeId) -> Result<Self>
Sourcepub fn is_within(&self, parent: NodeId) -> Result<bool>
pub fn is_within(&self, parent: NodeId) -> Result<bool>
Whether this Scope’s construction parent is the supplied live node or one of its staged descendants. Reads semantic ancestry only; hidden and suspended nodes remain valid, with no host query or commit barrier.
Sourcepub fn contains_node(&self, ancestor: NodeId, node: NodeId) -> Result<bool>
pub fn contains_node(&self, ancestor: NodeId, node: NodeId) -> Result<bool>
Whether the current staged semantic subtree rooted at ancestor
contains node, including the ancestor itself. Both identities and
this requesting Scope must still be live. Hidden, suspended and boxless
nodes keep their logical ancestry; use is_active separately before a
physical observation. No flush, host lookup or construction-parent
assumption is involved, so explicit Place is visible immediately.
pub fn retain(&self, resource: impl Any) -> Result
pub fn create(&self, descriptor: Descriptor) -> Result<NodeId>
pub fn patch(&self, id: NodeId, patch: Patch) -> Result
Sourcepub fn place(
&self,
node: NodeId,
parent: Option<NodeId>,
before: Option<NodeId>,
) -> Result
pub fn place( &self, node: NodeId, parent: Option<NodeId>, before: Option<NodeId>, ) -> Result
Move a live semantic range to an explicit parent, retaining its original Owner. Shared placement rules and adapter preflight run before changing the model or queue; suspended ranges resume through the same path.
Sourcepub fn link_request(&self, id: NodeId) -> Result<(String, LinkOpen)>
pub fn link_request(&self, id: NodeId) -> Result<(String, LinkOpen)>
Read the accepted semantic link target/context without host I/O or a commit barrier. A rejected source update never changes this snapshot.
pub fn action(&self, action: Action) -> Result
Sourcepub fn set_file_configuration(
&self,
node: NodeId,
configuration: FileConfig,
) -> Result<u64>
pub fn set_file_configuration( &self, node: NodeId, configuration: FileConfig, ) -> Result<u64>
Validate a complete finite configuration before allocating a revision. Equal declarations preserve the current selection and request lifetime.
pub fn clear_files(&self, node: NodeId) -> Result
pub fn remove_file(&self, file: FileToken) -> Result
pub fn pick_files(&self, node: NodeId) -> Result<u64>
Sourcepub fn copy_text(&self, node: NodeId) -> Result<u64>
pub fn copy_text(&self, node: NodeId) -> Result<u64>
Queue an explicit text write from this live Button’s accepted source. The returned identity is strictly increasing for its NodeId lifetime.
Sourcepub fn set_input_selection(
&self,
node: NodeId,
selection: TextSelection,
) -> Result
pub fn set_input_selection( &self, node: NodeId, selection: TextSelection, ) -> Result
Queue an exact UTF-16 selection using this Input’s current program revision. Call after set_input_value when formatting changed the value. Surrogate interiors are invalid; a host may refuse subcluster positions.
Sourcepub fn set_rich_document(
&self,
node: NodeId,
document: Rc<RichDocument>,
) -> Result<u64>
pub fn set_rich_document( &self, node: NodeId, document: Rc<RichDocument>, ) -> Result<u64>
Explicit program document write, even when equal, acknowledges or rejects a physical draft using a new revision from the live node.
Sourcepub fn rich_editor_value(&self, node: NodeId) -> Result<(Rc<RichDocument>, u64)>
pub fn rich_editor_value(&self, node: NodeId) -> Result<(Rc<RichDocument>, u64)>
Read staged accepted state, without a host query or flush.
pub fn rich_editor_editable(&self, node: NodeId) -> Result<bool>
pub fn set_rich_selection( &self, node: NodeId, selection: RichSelection, ) -> Result
Sourcepub fn bounds_now(&self, node: NodeId) -> Result<Option<Rect>>
pub fn bounds_now(&self, node: NodeId) -> Result<Option<Rect>>
Observe bounds at a committed barrier on hosts with an immediate read.
On other hosts, request Query::Bounds for a queued response.
Sourcepub fn request(
&self,
query: Query,
reply: impl FnOnce(Result<QueryValue, RenderError>) + 'static,
) -> Result<QueryToken>
pub fn request( &self, query: Query, reply: impl FnOnce(Result<QueryValue, RenderError>) + 'static, ) -> Result<QueryToken>
Flush before observing a host value. The reply executes under this Scope’s Owner, independent of the target’s Owner or the pump caller. Scope disposal drops its waiters without calling user code; a removed target completes a still-live request with NodeGone. No Scope is retained.
Sourcepub fn cancel_request(&self, token: QueryToken) -> Result<bool>
pub fn cancel_request(&self, token: QueryToken) -> Result<bool>
Revoke this Scope’s pending reply without attempting to undo host work. Tokens are local to their App. Missing/completed tokens return false; another live Scope’s token is rejected before either index is changed.
Sourcepub fn supports_plot_pointer(&self) -> Result<bool>
pub fn supports_plot_pointer(&self) -> Result<bool>
Explicit finite plot input support, independent of ordinary Pointer.
pub fn capabilities(&self) -> Result<Capabilities>
pub fn style_profile(&self) -> Result<Profile>
pub fn is_active(&self, node: NodeId) -> Result<bool>
Sourcepub fn is_enabled(&self, node: NodeId) -> Result<bool>
pub fn is_enabled(&self, node: NodeId) -> Result<bool>
Current semantic enabled ancestry, without a host query or flush. This
is independent of placement/visibility, which is_active checks.
Sourcepub fn defer_descendant_disposal(&self, node: NodeId) -> Result
pub fn defer_descendant_disposal(&self, node: NodeId) -> Result
Keep this owned node out of an earlier child’s retired-ancestor coalescing. Its own Owner cleanup still disposes it normally. This lets that Owner move live foreign ranges before their semantic parent dies; it does not keep the Owner or its own descendants alive. The marker is reclaimed whenever the node is disposed, including ancestor disposal.
Sourcepub fn is_inert(&self, node: NodeId) -> Result<bool>
pub fn is_inert(&self, node: NodeId) -> Result<bool>
Current inherited inert state. This reads the logical live tree only.
pub fn on( &self, node: NodeId, kind: EventKind, handler: impl FnMut(Event) + 'static, ) -> Result
Source§impl Scope
impl Scope
Sourcepub fn set_input_value(&self, node: NodeId, value: impl Into<String>) -> Result
pub fn set_input_value(&self, node: NodeId, value: impl Into<String>) -> Result
Write a text input using the next revision of the live semantic node. Equal values still acknowledge host edits without resetting caret/preedit. Call after a host tick (for example in an owned Effect), so later events from that tick retain their original revision until routing completes.
Sourcepub fn set_select_selection(
&self,
node: NodeId,
keys: Vec<SemanticId>,
) -> Result
pub fn set_select_selection( &self, node: NodeId, keys: Vec<SemanticId>, ) -> Result
Reconcile a native select after a complete host tick using its live revision.
Sourcepub fn set_image_source(
&self,
node: NodeId,
source: impl Into<String>,
) -> Result
pub fn set_image_source( &self, node: NodeId, source: impl Into<String>, ) -> Result
Start a new image request revision, including an explicit same-URL retry.
Sourcepub fn report_error(&self, error: impl Into<Error>)
pub fn report_error(&self, error: impl Into<Error>)
Report a custom widget’s asynchronous Binding/Effect/handler error at the next App flush. Retired scopes ignore late errors without retaining App.
Methods from Deref<Target = Scope>§
pub fn id(&self) -> InstanceId
pub fn owner(&self) -> &Owner
Sourcepub fn has_task_host(&self) -> Result<bool, AccessError>
pub fn has_task_host(&self) -> Result<bool, AccessError>
Whether this live Scope has an explicitly installed task execution service. This neither constructs/polls a future nor asks the host to perform work. An installed but closed/limited host still reports its normal spawn error.
pub fn child(&self) -> Scope
pub fn parent(&self) -> Option<InstanceId>
pub fn is_alive(&self) -> bool
Methods from Deref<Target = Owner>§
Sourcepub fn resource<K, T, E, F>(
&self,
source: impl Fn() -> K + 'static,
load: impl Fn(K) -> F + 'static,
) -> Resource<K, T, E>
pub fn resource<K, T, E, F>( &self, source: impl Fn() -> K + 'static, load: impl Fn(K) -> F + 'static, ) -> Resource<K, T, E>
Start/restart after tracked source-key changes at the effect phase. A missing Host produces Unavailable rather than a blocking fallback.
pub fn resource_seeded<K, T, E, F>( &self, source: impl Fn() -> K + 'static, load: impl Fn(K) -> F + 'static, seed: Option<ResourceSeed<K, T, E>>, ) -> Resource<K, T, E>
pub fn keyed_list<K, T>( &self, initial: Vec<T>, key: impl Fn(&T) -> K + 'static, ) -> Result<KeyedList<K, T>, ListError>
pub fn selector<K>( &self, source: Cage<Option<K>>, ) -> Result<Selector<K>, AccessError>
Sourcepub fn enter<R>(&self, f: impl FnOnce() -> R) -> R
pub fn enter<R>(&self, f: impl FnOnce() -> R) -> R
Derived maps created by this widget/factory belong to this owner, even when their source is application-wide. The context never owns data.
pub fn runtime(&self) -> RuntimeId
pub fn is_alive(&self) -> bool
Sourcepub fn check_write(&self) -> Result<(), AccessError>
pub fn check_write(&self) -> Result<(), AccessError>
Check liveness and mutation permission before an adapter changes host state. This publishes nothing and does not reserve a later source write.
pub fn child(&self) -> Owner
pub fn dispose(&self)
Sourcepub fn on_cleanup(
&self,
cleanup: impl FnOnce() + 'static,
) -> Result<(), AccessError>
pub fn on_cleanup( &self, cleanup: impl FnOnce() + 'static, ) -> Result<(), AccessError>
Run untracked after this Owner and its descendants have been invalidated. Implicit map/path construction remains in the retired Owner and fails; explicit entry into another live Owner is allowed. Callbacks run without graph borrows, in reverse registration order (children before parents). A panic unwinds normally; there is no catch/retry of remaining callbacks.
pub fn cage<T>(&self, value: T) -> Cage<T>where
T: 'static,
Sourcepub fn compute<T>(&self, f: impl FnOnce() -> T) -> Result<T, AccessError>
pub fn compute<T>(&self, f: impl FnOnce() -> T) -> Result<T, AccessError>
Synchronous, untracked pure computation under this live Owner. Allocates no reactive node. Both reads and unwind restore the outer tracking/mode/construction context; writes/creation remain forbidden.
pub fn bond<T>(&self, mapper: impl Fn() -> T + 'static) -> Bond<T>where
T: 'static,
pub fn binding(&self, callback: impl FnMut() + 'static) -> BindingId
Sourcepub fn effect(&self, callback: impl FnMut() + 'static) -> BindingId
pub fn effect(&self, callback: impl FnMut() + 'static) -> BindingId
Effects run after currently queued bindings. Writes enqueue another pass; reads still form direct dependencies, and runaway loops fail explicitly.
Sourcepub fn structural(&self, callback: impl FnMut() + 'static) -> BindingId
pub fn structural(&self, callback: impl FnMut() + 'static) -> BindingId
Structural controllers update owned row state before prop bindings run. Use this for tree control flow; ordinary computed props remain pure.