Skip to main content

Runtime

Struct Runtime 

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

Retained application execution, input dispatch and frame coordination.

Implementations§

Source§

impl Runtime

Source

pub fn new(root: Widget) -> Result<Self, TreeError>

Source

pub fn id(&self) -> u64

Stable identity of this runtime’s driver domain, for outlet ownership diagnostics: pairs with the outlet id to name both sides of a driver conflict.

Source

pub fn spawner(&self) -> RuntimeSpawner

Starts work owned by this retained root. Component code should prefer the build context’s spawn API so completion lifetime follows its owner.

Source

pub fn dispatcher(&self) -> UiDispatcher

Sends a Send callback from any worker thread to the UI owner. The callback is never run concurrently with retained-tree mutation.

Source

pub fn tokio_handle(&self) -> TokioHandle

Returns the application’s Tokio handle for advanced libraries. Direct Tokio tasks have Tokio/application lifetime and are not component-owned.

Source

pub fn set_wake_handler(&mut self, wake: Arc<dyn RuntimeWake>)

Source

pub const fn window_id(&self) -> Option<WindowId>

Returns the owning normalized window when this runtime is managed by a multi-window application. Standalone runtimes remain windowless.

Source

pub fn request_frame(&mut self)

Marks only this retained root for a future presentation.

Source

pub fn take_text_input_commands(&mut self) -> Vec<TextInputCommand>

Drains native text-input commands produced since the last platform event-loop turn. A desktop runner applies these to Winit; mobile hosts can translate the same data to their platform text services.

Source

pub fn open_window( &mut self, options: WindowOptions, root: Widget, ) -> Result<WindowHandle, WindowError>

Opens a second retained root through the owning application. This can be called from a build or a UI completion; native creation is queued for the desktop event-loop callback.

Source

pub fn window_opener(&self) -> Option<WindowOpener>

Returns a retained UI capability that callbacks may use to open a window after this build has returned.

Source

pub fn window_handle(&self) -> Option<WindowHandle>

Returns a command handle for this retained root’s owning native window.

Source

pub fn window_task_scope(&self) -> TaskScope

Returns the scope cancelled as soon as this window closes. Child component scopes inherit from it automatically.

Source

pub fn spawn_blocking<T>( &self, work: impl FnOnce() -> T + Send + 'static, complete: impl FnOnce(Result<T, TaskFailure>, &mut Runtime) + 'static, ) -> TaskHandle
where T: Send + 'static,

Starts bounded blocking work. Its completion callback runs later on the UI thread, so it may safely update a local Signal or schedule a build.

Source

pub fn spawn<F, T>(&self, future: F) -> Task<T>
where F: Future<Output = T> + Send + 'static, T: Send + 'static,

Starts Tokio work cancelled with this window. Use a BuildContext for work whose completion must be tied to a mounted declarative owner.

Source

pub fn spawn_into<F, T>( &self, future: F, complete: impl FnOnce(Result<T, TaskFailure>, &mut Runtime) + 'static, ) -> TaskHandle
where F: Future<Output = T> + Send + 'static, T: Send + 'static,

Starts window-scoped Tokio work with a UI-thread completion.

Source

pub fn process_runtime_work_at(&mut self, _now: Instant)

Processes a bounded batch of UI-relevant Tokio completion messages and dispatch callbacks. Native runners call this only from their user-event path; it never polls Tokio or implies a redraw.

Source

pub fn process_runtime_work(&mut self)

Source

pub fn runtime_diagnostics(&self) -> RuntimeDiagnostics

Source

pub fn debug_dump(&self) -> String

Compact ownership-facing state for framework diagnostics. Tokio’s own tracing ecosystem remains the source of executor-level telemetry.

Source

pub fn environment(&self) -> RuntimeEnvironment

Source

pub const fn lifecycle(&self) -> ApplicationLifecycle

Source

pub const fn environment_generation(&self) -> u64

Source

pub fn set_environment(&mut self, environment: RuntimeEnvironment) -> bool

Replaces normalized runtime values from a platform event. Rebuild is requested only when the declarative root read a changed value.

Source

pub fn transition_lifecycle(&mut self, lifecycle: ApplicationLifecycle) -> bool

Source

pub fn observe_lifecycle( &mut self, observer: impl Fn(LifecycleTransition) + 'static, )

Source

pub fn observe_runtime_error( &mut self, observer: impl Fn(RuntimeErrorReport) + 'static, )

Source

pub fn shutdown(&mut self)

Cancels runtime-owned work and prevents later queued callbacks from touching retained state. Native runners should call this before their renderer/window teardown.

Source

pub fn tree(&self) -> &WidgetTree

Source

pub fn tree_mut(&mut self) -> &mut WidgetTree

Source

pub fn content_sensitivity(&self) -> ContentSensitivity

Returns the effective capture-protection policy contributed by the mounted retained tree. The window/application boundary is responsible for forwarding changes to its native adapter.

Source

pub fn transient_surfaces(&self) -> Vec<TransientSurfaceSnapshot>

Visible transient portals after the latest layout. Desktop adapters use this retained snapshot to bind popup presentation to the owning window without coupling controls to a native event loop.

Source

pub fn set_native_transient_bounds(&mut self, bounds: Option<Rect>) -> bool

Updates the parent-local logical rectangle that confirmed native transient hosts may use for collision placement.

Source

pub fn set_native_transient_presentations( &mut self, ids: impl IntoIterator<Item = TransientSurfaceId>, ) -> bool

Updates the set of retained transients whose native hosts have completed negotiation. A presentation change requests a frame so placement, semantics, hit testing, and rendering switch coordinate spaces together.

Source

pub fn dismiss_transients(&mut self, reason: TransientDismissReason) -> bool

Applies a framework-level transient dismissal cause without changing native focus ownership. Controllers receive the callback and the normal retained rebuild path removes their popup subtree.

Source

pub fn set_animation_time_scale(&mut self, scale: f32)

Sets the animation-only time scale for this retained root. Runtime messages, Tokio tasks and profiler wall-clock measurements remain on the platform monotonic clock.

Source

pub fn focused_element(&self) -> Option<ElementId>

Source

pub fn dispatch_semantic_action( &mut self, node: SemanticNodeId, action: SemanticAction, ) -> bool

Dispatches an owned semantic action through the same control state used by pointer and keyboard input. Native adapters queue these requests; they never borrow mutable element storage. Eligibility reuses the existing owners: explicit semantic callbacks always execute; built-in Activate additionally requires the advertisement predicate (enabled button with a bound callback), matching the pointer and keyboard paths, which never see a disabled button past their own enabled gate. SetText requires an editable field while SetSelection requires only a controller — selection stays available in read-only and disabled fields on every input path. Focus accepts only targets the tree’s own focusability owner admits (can_request_focus: enabled controls, selectable text, or a focus node, unobstructed by exclude_focus or a hidden IndexedStack slot), with an already-focused valid target still reporting success; set_focus remains the single focus owner for all paths.

Source

pub fn focus_diagnostics(&self) -> FocusDiagnostics

Source

pub const fn editing_diagnostics(&self) -> EditingDiagnostics

Source

pub fn set_text_shortcut_platform(&mut self, platform: TextShortcutPlatform)

Chooses which platform’s text-editing shortcut table text fields use (Flutter’s defaultTargetPlatform): Option for words and Command for lines on macOS and iOS, Control for words elsewhere. Defaults to the platform this build targets.

Source

pub fn text_shortcut_platform(&self) -> TextShortcutPlatform

The platform whose text-editing shortcuts are active.

Source

pub fn set_clipboard(&mut self, clipboard: Box<dyn Clipboard>)

Source

pub fn clipboard_capabilities(&self) -> ClipboardCapabilities

Returns the capabilities of the clipboard backend currently installed for this retained window.

Source

pub fn read_clipboard( &mut self, request: TransferReadRequest, ) -> Result<DataTransfer, ClipboardError>

Reads rich clipboard data without collapsing it to plain text.

Source

pub fn write_clipboard( &mut self, transfer: DataTransfer, ) -> Result<ClipboardWriteReport, ClipboardError>

Writes one rich clipboard transfer. The report distinguishes formats written atomically by the backend from representations it skipped.

Source

pub fn set_clipboard_text(&mut self, text: impl Into<String>)

Source

pub fn handle_external_drag( &mut self, event: ExternalDragEvent, ) -> ExternalDragResponse

Routes platform-owned transfer data through external drop targets. This path is intentionally independent of the local typed gesture arena.

Source

pub fn handle_platform_event( &mut self, event: PlatformEvent, ) -> Option<EventTarget>

Processes a normalized platform event without exposing native window or event-loop types to the runtime API.

Source

pub fn update_window_metrics(&mut self, metrics: WindowMetrics) -> bool

Applies the authoritative logical/physical conversion supplied by the platform metrics owner. Existing environment values such as locale are preserved while size and scale change together.

Source

pub fn register_builder( &mut self, id: ElementId, builder: impl FnMut() -> Widget + 'static, ) -> Result<(), TreeError>

Source

pub fn schedule_update( &mut self, id: ElementId, widget: Widget, ) -> Result<(), TreeError>

Source

pub fn frame_requested(&self) -> bool

Source

pub fn handle_input(&mut self, event: InputEvent) -> Option<EventTarget>

Source

pub fn set_diagnostic_trigger(&self, trigger: impl Into<String>)

Associates subsequent frame work with a higher-level command such as a semantic simulation click. The trigger survives the input callback so deferred build/layout failures retain their original cause.

Source

pub fn effective_mouse_cursor(&self) -> MouseCursor

Cursor selected by the current retained hover route. Defer is resolved to the ordinary platform cursor before crossing the native boundary.

Source

pub fn handle_text_input_action(&mut self, action: TextInputAction) -> bool

Handles the action chosen by a native software keyboard. Desktop Winit backends reach the same code path through Enter, while mobile hosts can preserve the IME’s explicit Done/Next/Search intent.

Source

pub fn run_frame( &mut self, constraints: Constraints, ) -> Result<(DisplayList, FrameStats), TreeError>

Source

pub fn run_frame_at( &mut self, constraints: Constraints, now: Instant, ) -> Result<(DisplayList, FrameStats), TreeError>

Deterministic frame entry point used by animation tests and embedders with an existing monotonic clock.

Source

pub fn diagnostics(&self) -> Diagnostics

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T, C> AdaptIntoUnclamped<T> for C
where T: AdaptFromUnclamped<C>,

Source§

type Scalar = <T as AdaptFromUnclamped<C>>::Scalar

The number type that’s used as the color’s components.
Source§

fn adapt_into_unclamped_with<M>(self) -> T

Adapt a color of type Self into a color of type T, using the custom matrix M. Read more
Source§

fn adapt_into_unclamped(self) -> T
where Bradford: LmsToXyz<Self::Scalar> + XyzToLms<Self::Scalar>,

Adapt a color of type Self into a color of type T, using the Bradford matrix. Read more
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T, C> ComponentsInto<C> for T

Source§

fn components_into(self) -> C

Cast this collection of color components into a collection of colors. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
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, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
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> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
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, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
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