pub struct ScriptViewHandle(/* private fields */);Implementations§
Source§impl ScriptViewHandle
impl ScriptViewHandle
pub fn view_id(&self) -> &str
pub fn state(&self) -> ScriptViewState
Sourcepub fn collection_scroll_handle(
&self,
id: &VirtualCollectionId,
cx: &App,
) -> Result<Option<VirtualCollectionScrollHandle>, ScriptViewError>
pub fn collection_scroll_handle( &self, id: &VirtualCollectionId, cx: &App, ) -> Result<Option<VirtualCollectionScrollHandle>, ScriptViewError>
Resolve a mounted collection’s native scrolling capability. The ID must belong to this view’s component scope; equal keys in other views cannot resolve here. Resolve again after replacement instead of retaining a handle to a removed collection.
§Errors
Returns after suspension or disposal.
Sourcepub fn theme(&self) -> Result<ThemeHandle, ScriptViewError>
pub fn theme(&self) -> Result<ThemeHandle, ScriptViewError>
Return a read-only, observable handle to this view’s effective theme.
§Errors
Returns ScriptViewError::DisposedView after explicit disposal.
Sourcepub fn theme_snapshot(&self, cx: &App) -> Result<ThemeSnapshot, ScriptViewError>
pub fn theme_snapshot(&self, cx: &App) -> Result<ThemeSnapshot, ScriptViewError>
Read this view’s latest effective theme without invoking Rhai.
§Errors
Returns ScriptViewError::DisposedView after explicit disposal.
Sourcepub fn select_theme(
&self,
family: &str,
variant: &str,
cx: &mut App,
) -> Result<bool, ScriptViewError>
pub fn select_theme( &self, family: &str, variant: &str, cx: &mut App, ) -> Result<bool, ScriptViewError>
Select this view’s app-level theme from trusted Host code.
§Errors
Returns after disposal or when the requested theme is unavailable.
Sourcepub fn select_locale(
&self,
locale: &str,
cx: &mut App,
) -> Result<bool, ScriptViewError>
pub fn select_locale( &self, locale: &str, cx: &mut App, ) -> Result<bool, ScriptViewError>
Select this view’s app-level locale from trusted Host code.
§Errors
Returns after disposal or when the requested locale is unavailable.
Sourcepub fn set_motion_preference(
&self,
preference: MotionPreference,
cx: &mut App,
) -> Result<bool, ScriptViewError>
pub fn set_motion_preference( &self, preference: MotionPreference, cx: &mut App, ) -> Result<bool, ScriptViewError>
Replace this view’s Host-owned motion preference without resetting state.
§Errors
Returns after disposal.
Sourcepub fn root(&self, cx: &App) -> Result<Option<UiNode>, ScriptViewError>
pub fn root(&self, cx: &App) -> Result<Option<UiNode>, ScriptViewError>
Return the last successfully committed declarative tree.
A failed transaction rolls back, so this is always a committed tree,
never a partial candidate. Self::last_error reports whether some
script work failed since the last reload or Self::clear_error.
§Errors
Returns ScriptViewError::DisposedView after disposal.
Sourcepub fn committed_revision(&self, cx: &App) -> Result<u64, ScriptViewError>
pub fn committed_revision(&self, cx: &App) -> Result<u64, ScriptViewError>
The revision of the view’s committed tree. It advances whenever a render commits, so Host work that depends only on the committed composition (an audit, a snapshot) can skip frames that merely repaint.
§Errors
Returns ScriptViewError::DisposedView after disposal.
Sourcepub fn dropped_file_path(
&self,
handle: &OpaqueHandle,
cx: &App,
) -> Result<Option<PathBuf>, ScriptViewError>
pub fn dropped_file_path( &self, handle: &OpaqueHandle, cx: &App, ) -> Result<Option<PathBuf>, ScriptViewError>
The path of a file or folder dropped from the operating system, by the
opaque file handle its drop event gave the script
(ScriptView::accept_file_drops); None for any other handle. A
capability handler, which gets no App, uses a clone of
crate::UiRuntimeState::dropped_files instead.
§Errors
Returns ScriptViewError::DisposedView after disposal.
Sourcepub fn last_error(&self, cx: &App) -> Result<Option<String>, ScriptViewError>
pub fn last_error(&self, cx: &App) -> Result<Option<String>, ScriptViewError>
Return the latest mounted-view render, callback, delivery, or reload error.
A failed transaction rolls back to the last committed tree, and the view
keeps working, so later transactions usually succeed. The error stays
until a successful reload or Self::clear_error; otherwise a failure
in one event would be gone before anyone could read it.
§Errors
Returns ScriptViewError::DisposedView after disposal.
Sourcepub fn last_diagnostic(
&self,
cx: &App,
) -> Result<Option<Diagnostic>, ScriptViewError>
pub fn last_diagnostic( &self, cx: &App, ) -> Result<Option<Diagnostic>, ScriptViewError>
Return structured details for the latest script runtime error.
Non-script host errors only have a string representation and return
None here.
§Errors
Returns ScriptViewError::DisposedView after disposal.
Sourcepub fn clear_error(&self, cx: &mut App) -> Result<(), ScriptViewError>
pub fn clear_error(&self, cx: &mut App) -> Result<(), ScriptViewError>
Acknowledge the reported error: Self::last_error returns None and
the built-in banner closes until the next failure.
§Errors
Returns ScriptViewError::DisposedView after disposal.
Sourcepub fn take_performance_snapshot(
&self,
cx: &mut App,
) -> Result<ScriptViewPerformanceSnapshot, ScriptViewError>
pub fn take_performance_snapshot( &self, cx: &mut App, ) -> Result<ScriptViewPerformanceSnapshot, ScriptViewError>
Drain execution timings and snapshot retained/virtual metrics.
§Errors
Returns ScriptViewError::DisposedView after disposal.
Sourcepub fn read_signal(
&self,
signal: &NativeSignal,
cx: &App,
) -> Result<SignalValue, ScriptViewError>
pub fn read_signal( &self, signal: &NativeSignal, cx: &App, ) -> Result<SignalValue, ScriptViewError>
Read one mounted native hot value without invoking Rhai.
§Errors
Returns after disposal or when the signal is stale.
Sourcepub fn write_signal(
&self,
signal: &NativeSignal,
value: SignalValue,
cx: &mut App,
) -> Result<bool, ScriptViewError>
pub fn write_signal( &self, signal: &NativeSignal, value: SignalValue, cx: &mut App, ) -> Result<bool, ScriptViewError>
Update one mounted native hot value on the GPUI foreground thread.
This repaints signal-bound properties without running a Rhai component.
§Errors
Returns after disposal or for stale/type-incompatible values.
Sourcepub fn replace_native_collection(
&self,
name: &str,
collection: NativeCollection,
cx: &mut App,
) -> Result<bool, ScriptViewError>
pub fn replace_native_collection( &self, name: &str, collection: NativeCollection, cx: &mut App, ) -> Result<bool, ScriptViewError>
Replace one registered Rust-owned collection on the GPUI foreground thread.
Only components that read this collection are marked dirty. The replacement is immutable and can be prepared away from the Rhai runtime.
§Errors
Returns after disposal or when the collection name is unknown.
Sourcepub fn register_native_collection(
&self,
name: &str,
collection: NativeCollection,
cx: &mut App,
) -> Result<(), ScriptViewError>
pub fn register_native_collection( &self, name: &str, collection: NativeCollection, cx: &mut App, ) -> Result<(), ScriptViewError>
Register a new Rust-owned collection on an already mounted view.
The name must not already exist. Registration marks the view root dirty; an active view rerenders on the next foreground cycle, while a suspended view consumes the collection when it resumes.
§Errors
Returns after disposal or for an unsafe/duplicate collection name.
Sourcepub fn register_native_text_document(
&self,
name: &str,
document: NativeTextDocument,
cx: &mut App,
) -> Result<(), ScriptViewError>
pub fn register_native_text_document( &self, name: &str, document: NativeTextDocument, cx: &mut App, ) -> Result<(), ScriptViewError>
Register a Host-owned document after mount, invalidating only components that previously attempted to read this name. No preallocated pool is needed.
§Errors
Returns after disposal or for an invalid/duplicate name.
Sourcepub fn release_native_text_document(
&self,
name: &str,
cx: &mut App,
) -> Result<bool, ScriptViewError>
pub fn release_native_text_document( &self, name: &str, cx: &mut App, ) -> Result<bool, ScriptViewError>
Release this name’s registry ownership. In-flight viewers retain their
immutable snapshot safely; stop referring to the name before releasing it.
The boolean reports whether readers were invalidated; a successful
false result still released the registry’s snapshot.
§Errors
Returns after disposal or for an unknown name.
Sourcepub fn replace_native_text_document(
&self,
name: &str,
document: NativeTextDocument,
cx: &mut App,
) -> Result<bool, ScriptViewError>
pub fn replace_native_text_document( &self, name: &str, document: NativeTextDocument, cx: &mut App, ) -> Result<bool, ScriptViewError>
Replace one registered Host-owned text document revision.
Only components that read this document are invalidated. The immutable text snapshot may be prepared on a background thread before publication.
§Errors
Returns after disposal or when the document name is unknown.
Sourcepub fn append_native_text_document(
&self,
name: &str,
text: &str,
cx: &mut App,
) -> Result<bool, ScriptViewError>
pub fn append_native_text_document( &self, name: &str, text: &str, cx: &mut App, ) -> Result<bool, ScriptViewError>
Append text to one registered Host-owned document as its next revision
(the same identity, the following revision): a streamed reply sends each
chunk instead of the whole text so far. A MarkdownViewer reading it then
prepares only the last block and the new text, not the whole reply.
§Errors
Returns after disposal, when the document name is unknown, or when its revision cannot advance.
Sourcepub fn element(&self) -> Result<AnyElement, ScriptViewError>
pub fn element(&self) -> Result<AnyElement, ScriptViewError>
Return the measured embedding element.
§Errors
Returns ScriptViewError::DisposedView after explicit disposal.
Sourcepub fn flex_item(&self) -> Result<AnyElement, ScriptViewError>
pub fn flex_item(&self) -> Result<AnyElement, ScriptViewError>
Return the measured view as a zero-basis, shrinkable host flex item.
Use this as the direct child of a Rust flex row or column. It prevents horizontally scrollable script content from contributing an automatic min-content width that expands the surrounding host layout.
§Errors
Returns ScriptViewError::DisposedView after explicit disposal.
Sourcepub fn suspend(
&self,
window: &mut Window,
cx: &mut App,
) -> Result<bool, ScriptViewError>
pub fn suspend( &self, window: &mut Window, cx: &mut App, ) -> Result<bool, ScriptViewError>
Quiesce this retained view without discarding script or native UI state.
§Errors
Returns after disposal or when a suspend hook/effect cleanup fails.
Sourcepub fn resume(&self, cx: &mut App) -> Result<bool, ScriptViewError>
pub fn resume(&self, cx: &mut App) -> Result<bool, ScriptViewError>
Atomically resume a suspended view before returning it to Host layout.
§Errors
Returns after disposal or when pending delivery, resume hook, reload, or the first restored render fails. A compensable failure leaves the view suspended; failed compensation disposes and quarantines the view.
Sourcepub fn dispose(&self, cx: &mut App) -> Result<(), ScriptViewError>
pub fn dispose(&self, cx: &mut App) -> Result<(), ScriptViewError>
Dispose this view immediately. The operation is idempotent.
§Errors
Returns an entity update error only if GPUI has already released the underlying view unexpectedly.
Sourcepub fn composition_audit(
&self,
cx: &App,
) -> Result<Vec<AuditFinding>, ScriptViewError>
pub fn composition_audit( &self, cx: &App, ) -> Result<Vec<AuditFinding>, ScriptViewError>
Audit the committed composition with the rules of this view’s profile
(ui/profile.rhai or ScriptView::profile_source). With no
profile the result is empty.
§Errors
Returns after disposal.
Sourcepub fn composition_audit_with(
&self,
rules: &AuditRules,
cx: &App,
) -> Result<Vec<AuditFinding>, ScriptViewError>
pub fn composition_audit_with( &self, rules: &AuditRules, cx: &App, ) -> Result<Vec<AuditFinding>, ScriptViewError>
Sourcepub fn accessibility_snapshot(
&self,
cx: &App,
) -> Result<AccessibilityTree, ScriptViewError>
pub fn accessibility_snapshot( &self, cx: &App, ) -> Result<AccessibilityTree, ScriptViewError>
Snapshot the retained semantic tree and last committed geometry.
§Errors
Returns after disposal or for an invalid retained semantic graph.
Sourcepub fn automation_snapshot(
&self,
cx: &App,
) -> Result<AutomationSnapshot, ScriptViewError>
pub fn automation_snapshot( &self, cx: &App, ) -> Result<AutomationSnapshot, ScriptViewError>
Snapshot the stable language-neutral automation tree.
§Errors
Returns after disposal or for an invalid retained semantic graph.
Sourcepub fn automate(
&self,
command: AutomationCommand,
window: &mut Window,
cx: &mut App,
) -> Result<AutomationResult, ScriptViewError>
pub fn automate( &self, command: AutomationCommand, window: &mut Window, cx: &mut App, ) -> Result<AutomationResult, ScriptViewError>
Execute one automation command on the GPUI foreground thread.
Dispatch and action commands use the mounted production handlers; deterministic time advance requires an injected controllable clock.
§Errors
Returns after disposal, for locator/command failures, or runtime errors.
Sourcepub fn reconcile_report(
&self,
cx: &App,
) -> Result<ReconcileReport, ScriptViewError>
pub fn reconcile_report( &self, cx: &App, ) -> Result<ReconcileReport, ScriptViewError>
Sourcepub fn focus_element(
&self,
reference: &ElementRef,
window: &mut Window,
cx: &mut App,
) -> Result<(), ScriptViewError>
pub fn focus_element( &self, reference: &ElementRef, window: &mut Window, cx: &mut App, ) -> Result<(), ScriptViewError>
Focus a mounted retained element without invoking Rhai.
§Errors
Returns after disposal, for a stale ref, or when the ref has no active GPUI focus handle.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ScriptViewHandle
impl !Send for ScriptViewHandle
impl !Sync for ScriptViewHandle
impl !UnwindSafe for ScriptViewHandle
impl Forget for ScriptViewHandle
impl Freeze for ScriptViewHandle
impl Move for ScriptViewHandle
impl Unpin for ScriptViewHandle
impl UnsafeUnpin for ScriptViewHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Variant for T
impl<T> Variant for T
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Variant trait object to &mut dyn Any.Source§fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
Variant trait object to Box<dyn Any>.