Skip to main content

Runtime

Struct Runtime 

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

Implementations§

Source§

impl Runtime

Source

pub fn new() -> Self

Source

pub fn add_window(&mut self, builder: WindowBuilder) -> Result<WindowId>

Source

pub fn set_external_waker(&mut self, waker: impl Fn() + Send + Sync + 'static)

Install the platform callback used to wake the UI after an observable invalidates one or more subscribed widgets.

Source

pub fn set_command_waker(&self, waker: impl Fn() + Send + Sync + 'static)

Install the platform callback used by the thread-safe command producer.

Source

pub fn command_sender(&self) -> CommandSender

Return the cloneable command producer associated with this runtime.

Source

pub fn has_pending_commands(&self) -> bool

Source

pub fn process_reactive_updates(&mut self)

Drain observable changes into targeted widget invalidations without delivering an application-level external wake event.

Platform integrations call this after their reactive wake signal.

Source

pub fn process_commands(&mut self)

Drain queued commands and scheduler-only wakes on the UI thread.

Platform integrations call this in response to the command producer’s waker. Delivery is independent of hit testing and widget ancestry.

Source

pub fn handle_command<T>( &mut self, target: CommandTarget, delivery: CommandDelivery, key: CommandKey<T>, payload: T, )
where T: Send + Sync + 'static,

Enqueue and synchronously drain a command. Intended for headless hosts and tests that own the runtime loop directly.

Source

pub fn clipboard(&self) -> Clipboard

Shared clipboard handle used by every window in this runtime.

Source

pub fn set_clipboard_backend(&self, backend: impl ClipboardBackend + 'static)

Install a clipboard storage driver (for example an OS-clipboard bridge provided by the platform). Existing windows pick it up immediately.

Source

pub fn remove_window(&mut self, window_id: WindowId) -> Result<()>

Source

pub fn handle_event(&mut self, window_id: WindowId, event: Event) -> Result<()>

Source

pub fn dispatch_event( &mut self, window_id: WindowId, event: Event, ) -> Result<bool>

Dispatch an event and report whether widget routing or a built-in runtime behavior consumed it.

Platform hosts can use this to provide native fallbacks only when application and runtime behavior did not handle an event. Most callers should continue to use Runtime::handle_event when the dispatch outcome is not relevant.

Source

pub fn handle_semantics_action( &mut self, window_id: WindowId, target: WidgetId, action: SemanticsActionRequest, ) -> Result<bool>

Invoke an action advertised by a node in the latest semantic snapshot.

The semantic node does not need to be a retained WidgetPod. Virtual and generated nodes are routed to their nearest graph-backed semantic ancestor while SemanticsEvent::target preserves the original node identity for widget-local dispatch. The return value is false when the node is stale, hidden, disabled, does not advertise the action, or no widget handles an action without a built-in runtime fallback.

Source

pub fn tick(&mut self, frame_time: f64)

Source

pub fn drain_ready_events(&mut self) -> Vec<(WindowId, Event)>

Source

pub fn next_wakeup_time(&self, window_id: WindowId) -> Result<Option<f64>>

Source

pub fn wake_async( &mut self, window_id: WindowId, token: AsyncWakeToken, ) -> Result<bool>

Source

pub fn wake_root(&mut self, window_id: WindowId) -> Result<()>

Explicitly deliver the legacy external-wake Event::Custom (kind EXTERNAL_WAKE_KIND) to a window’s root widget.

Platform wakes do not call this method. New integrations should enqueue a typed command or use CommandSender::wake with a controller.

Source

pub fn register_font( &mut self, handle: FontHandle, font: RegisteredFont, ) -> Result<()>

Source

pub fn register_font_bytes( &mut self, data: impl Into<Vec<u8>>, ) -> Result<FontHandle>

Source

pub fn register_image( &mut self, handle: ImageHandle, image: RegisteredImage, ) -> Result<()>

Source

pub fn register_svg_image_with_handle( &mut self, handle: ImageHandle, data: impl AsRef<[u8]>, ) -> Result<()>

Source

pub fn register_rgba_image( &mut self, width: u32, height: u32, data: impl Into<Vec<u8>>, ) -> Result<ImageHandle>

Source

pub fn register_svg_image( &mut self, data: impl AsRef<[u8]>, ) -> Result<ImageHandle>

Source

pub fn register_svg_image_at_size_with_handle( &mut self, handle: ImageHandle, width: u32, height: u32, data: impl AsRef<[u8]>, ) -> Result<()>

Source

pub fn register_svg_image_at_size( &mut self, width: u32, height: u32, data: impl AsRef<[u8]>, ) -> Result<ImageHandle>

Source

pub fn register_embedded_svg_image( &mut self, resource: EmbeddedSvgImageResource, ) -> Result<()>

Source

pub fn register_embedded_svg_images( &mut self, resources: impl IntoIterator<Item = EmbeddedSvgImageResource>, ) -> Result<()>

Source

pub fn font_registry(&self) -> &Arc<FontRegistry>

Source

pub fn image_registry(&self) -> &Arc<ImageRegistry>

Source

pub fn render(&mut self, window_id: WindowId) -> Result<RenderOutput>

Source

pub fn semantics(&self, window_id: WindowId) -> Result<&[SemanticsNode]>

Source

pub fn window_title(&self, window_id: WindowId) -> Result<&str>

Source

pub fn window_icon(&self, window_id: WindowId) -> Result<Option<&WindowIcon>>

Source

pub fn window_ids(&self) -> Vec<WindowId>

Source

pub fn needs_render(&self, window_id: WindowId) -> Result<bool>

Source

pub fn schedule(&self, window_id: WindowId) -> Result<FrameSchedule>

Source

pub fn focus_state(&self, window_id: WindowId) -> Result<FocusState>

Source

pub fn focused_widget(&self, window_id: WindowId) -> Result<Option<WidgetId>>

Source

pub fn pointer_capture_target( &self, window_id: WindowId, pointer_id: u64, ) -> Result<Option<WidgetId>>

Source

pub fn widget_graph(&self, window_id: WindowId) -> Result<WidgetGraphSnapshot>

Source

pub fn set_inspector_tracing( &mut self, window_id: WindowId, enabled: bool, ) -> Result<()>

Enable or disable bounded route and invalidation history for a window. Structural snapshots remain available while tracing is disabled.

Source

pub fn inspector_tracing(&self, window_id: WindowId) -> Result<bool>

Source

pub fn inspector_snapshot( &self, window_id: WindowId, ) -> Result<WindowInspectorSnapshot>

Capture a unified renderer-neutral snapshot for debug tooling.

Source

pub fn overlay_snapshot( &self, window_id: WindowId, ) -> Result<OverlayManagerSnapshot>

Inspect the window’s currently presented overlay stack.

Source

pub fn take_overlay_traces( &mut self, window_id: WindowId, ) -> Result<Vec<OverlayTraceSample>>

Drain overlay lifecycle and dismissal diagnostics for an inspector.

Trait Implementations§

Source§

impl Default for Runtime

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.