Skip to main content

ScriptLifecycle

Struct ScriptLifecycle 

Source
pub struct ScriptLifecycle { /* private fields */ }

Implementations§

Source§

impl ScriptLifecycle

Source

pub fn new( compiled: CompiledUi, runtime: Rc<RefCell<UiRuntimeState>>, root_path: ComponentInstancePath, window: Option<String>, events: BTreeMap<String, EventSchema>, state_schema: &ComponentStateSchema, ) -> Result<Self, LifecycleError>

Create an application lifecycle and mount its root component state.

§Errors

Returns LifecycleError when runtime state is already borrowed or the root state schema cannot mount.

Source

pub const fn state(&self) -> LifecycleState

Source

pub fn root(&self) -> Option<&UiNode>

Source

pub const fn retained(&self) -> &RetainedUiTree

Source

pub const fn semantics(&self) -> &CommittedSemanticFrame

Source

pub fn generation(&self) -> ScriptGeneration

Source

pub fn runtime(&self) -> Rc<RefCell<UiRuntimeState>>

Source

pub fn with_view_id(self, view: impl Into<String>) -> Self

Source

pub fn initialize( &mut self, engine: &RuntimeEngine, ) -> Result<(), LifecycleError>

Run optional init(ctx) exactly once.

§Errors

Returns LifecycleError::InvalidTransition outside Created, or a script evaluation error.

Source

pub fn validate_initial_view_without_init( &mut self, engine: &mut RuntimeEngine, ) -> Result<&UiNode, LifecycleError>

Validate the initial view(ctx) without executing init(ctx).

This entry point is for static tooling that has no Host capability implementations. It validates the rendered tree but deliberately does not claim that Host-dependent initialization succeeded.

§Errors

Returns the same render, reconciliation, and resource errors as Self::render.

Source

pub fn render( &mut self, engine: &mut RuntimeEngine, ) -> Result<&UiNode, LifecycleError>

Evaluate required view(ctx) and activate its generation on success.

§Errors

Returns LifecycleError::InvalidTransition before initialization or after disposal, or a script evaluation error.

Source

pub fn render_dirty( &mut self, engine: &mut RuntimeEngine, ) -> Result<bool, LifecycleError>

Rerender only the topmost dirty formal component subtrees.

Falls back to a complete root render when the root itself is dirty or a component has no active invocation recipe.

§Errors

Returns component invocation, script evaluation, reconciliation, or runtime-state rollback errors.

Source

pub fn realize_virtual_requests( &mut self, engine: &mut RuntimeEngine, ) -> Result<bool, LifecycleError>

Realize requested data-backed virtual items outside GPUI layout/paint.

§Errors

Returns renderer, retained reconciliation, effect, or rollback errors.

Source

pub fn dispose( &mut self, engine: &mut RuntimeEngine, ) -> Result<(), LifecycleError>

Run optional dispose(ctx) once and make the lifecycle terminal.

§Errors

Returns LifecycleError::InvalidTransition before initialization or after disposal, or a script evaluation error.

Source

pub fn suspend( &mut self, engine: &mut RuntimeEngine, ) -> Result<bool, LifecycleError>

Quiesce one retained view without discarding its tree, state, native entities, measurements, or current script generation.

§Errors

Returns lifecycle, callback, cleanup, or rollback errors. Repeated suspension is an idempotent no-op.

Source

pub fn resume( &mut self, engine: &mut RuntimeEngine, ) -> Result<bool, LifecycleError>

Resume a retained view transactionally against current Host data.

The optional resume(ctx, elapsed_ms) hook runs before one full render; effect declarations then restart with fresh activation identities.

§Errors

Returns lifecycle, callback, render, reconciliation, or rollback errors.

Source

pub fn invoke_callback( &self, engine: &RuntimeEngine, callback: &ScriptCallback, payload: UiValue, ) -> Result<Dynamic, LifecycleError>

Invoke a generation-bound event callback with (ctx, payload).

§Errors

Returns stale callback or Rhai evaluation errors.

Source

pub fn invoke_callback_transactional( &self, engine: &RuntimeEngine, callback: &ScriptCallback, payload: UiValue, ) -> Result<Dynamic, LifecycleError>

Invoke a foreground callback and roll back runtime UI state if it fails. External capability side effects are outside this transaction.

§Errors

Returns callback or runtime borrow errors.

Source

pub fn invoke_async_delivery( &self, engine: &RuntimeEngine, delivery: AsyncDelivery, ) -> Result<Dynamic, LifecycleError>

Invoke an async delivery in its owning component scope.

§Errors

Returns stale callback or Rhai evaluation errors.

Source

pub fn invoke_async_delivery_transactional( &self, engine: &RuntimeEngine, delivery: AsyncDelivery, ) -> Result<Dynamic, LifecycleError>

Deliver async work with the same UI-state rollback as foreground events.

§Errors

Returns callback or runtime borrow errors.

Source

pub fn invoke_component_event_transactional( &self, engine: &RuntimeEngine, pending: PendingEvent, ) -> Result<Option<Dynamic>, LifecycleError>

Deliver one declared component event to its rendered caller callback. Missing optional listeners are treated as intentionally unobserved.

§Errors

Returns callback or runtime borrow errors.

Source

pub fn reload( &mut self, engine: &mut RuntimeEngine, candidate: CompiledUi, state_schema: &ComponentStateSchema, ) -> Result<&UiNode, LifecycleError>

Transactionally run candidate init(ctx) and view(ctx) during hot reload.

Component/store state and the last-good AST/root are preserved when either candidate lifecycle stage fails.

§Errors

Returns runtime or borrow errors from the candidate generation.

Source

pub fn resume_reload( &mut self, engine: &mut RuntimeEngine, candidate: CompiledUi, state_schema: &ComponentStateSchema, ) -> Result<&UiNode, LifecycleError>

Resume a suspended retained view into a newer compiled generation.

Candidate initialization, the optional resume hook, reconciliation, and effect activation form one rollback-safe transaction. Async deliveries from the replaced generation must be discarded by the host before entering this transaction.

§Errors

Returns lifecycle, callback, render, reconciliation, or rollback errors.

Source

pub fn start( &mut self, engine: &mut RuntimeEngine, ) -> Result<&UiNode, LifecycleError>

Run initialization followed by the first render.

§Errors

Returns lifecycle or script errors from either stage.

Source

pub fn window_id(&self) -> Option<&str>

Source

pub fn view_id(&self) -> Option<&str>

Source

pub fn root_path(&self) -> &ComponentInstancePath

Source

pub fn compiled(&self) -> CompiledUi

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

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

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

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 = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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