pub struct Runtime { /* private fields */ }Implementations§
Source§impl Runtime
impl Runtime
pub fn new() -> Self
pub fn add_window(&mut self, builder: WindowBuilder) -> Result<WindowId>
Sourcepub fn set_external_waker(&mut self, waker: impl Fn() + Send + Sync + 'static)
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.
Sourcepub fn set_command_waker(&self, waker: impl Fn() + Send + Sync + 'static)
pub fn set_command_waker(&self, waker: impl Fn() + Send + Sync + 'static)
Install the platform callback used by the thread-safe command producer.
Sourcepub fn command_sender(&self) -> CommandSender
pub fn command_sender(&self) -> CommandSender
Return the cloneable command producer associated with this runtime.
pub fn has_pending_commands(&self) -> bool
Sourcepub fn process_reactive_updates(&mut self)
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.
Sourcepub fn process_commands(&mut self)
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.
Sourcepub fn handle_command<T>(
&mut self,
target: CommandTarget,
delivery: CommandDelivery,
key: CommandKey<T>,
payload: T,
)
pub fn handle_command<T>( &mut self, target: CommandTarget, delivery: CommandDelivery, key: CommandKey<T>, payload: T, )
Enqueue and synchronously drain a command. Intended for headless hosts and tests that own the runtime loop directly.
Sourcepub fn clipboard(&self) -> Clipboard
pub fn clipboard(&self) -> Clipboard
Shared clipboard handle used by every window in this runtime.
Sourcepub fn set_clipboard_backend(&self, backend: impl ClipboardBackend + 'static)
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.
pub fn remove_window(&mut self, window_id: WindowId) -> Result<()>
pub fn handle_event(&mut self, window_id: WindowId, event: Event) -> Result<()>
Sourcepub fn dispatch_event(
&mut self,
window_id: WindowId,
event: Event,
) -> Result<bool>
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.
Sourcepub fn handle_semantics_action(
&mut self,
window_id: WindowId,
target: WidgetId,
action: SemanticsActionRequest,
) -> Result<bool>
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.
pub fn tick(&mut self, frame_time: f64)
pub fn drain_ready_events(&mut self) -> Vec<(WindowId, Event)>
pub fn next_wakeup_time(&self, window_id: WindowId) -> Result<Option<f64>>
pub fn wake_async( &mut self, window_id: WindowId, token: AsyncWakeToken, ) -> Result<bool>
Sourcepub fn wake_root(&mut self, window_id: WindowId) -> Result<()>
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.
pub fn register_font( &mut self, handle: FontHandle, font: RegisteredFont, ) -> Result<()>
pub fn register_font_bytes( &mut self, data: impl Into<Vec<u8>>, ) -> Result<FontHandle>
pub fn register_image( &mut self, handle: ImageHandle, image: RegisteredImage, ) -> Result<()>
pub fn register_svg_image_with_handle( &mut self, handle: ImageHandle, data: impl AsRef<[u8]>, ) -> Result<()>
pub fn register_rgba_image( &mut self, width: u32, height: u32, data: impl Into<Vec<u8>>, ) -> Result<ImageHandle>
pub fn register_svg_image( &mut self, data: impl AsRef<[u8]>, ) -> Result<ImageHandle>
pub fn register_svg_image_at_size_with_handle( &mut self, handle: ImageHandle, width: u32, height: u32, data: impl AsRef<[u8]>, ) -> Result<()>
pub fn register_svg_image_at_size( &mut self, width: u32, height: u32, data: impl AsRef<[u8]>, ) -> Result<ImageHandle>
pub fn register_embedded_svg_image( &mut self, resource: EmbeddedSvgImageResource, ) -> Result<()>
pub fn register_embedded_svg_images( &mut self, resources: impl IntoIterator<Item = EmbeddedSvgImageResource>, ) -> Result<()>
pub fn font_registry(&self) -> &Arc<FontRegistry> ⓘ
Sourcepub fn text_preparation_cache_snapshot(&self) -> TextPreparationCacheSnapshot
pub fn text_preparation_cache_snapshot(&self) -> TextPreparationCacheSnapshot
Read-only cache diagnostics for measurement/profiling tools.
pub fn image_registry(&self) -> &Arc<ImageRegistry> ⓘ
pub fn render(&mut self, window_id: WindowId) -> Result<RenderOutput>
pub fn semantics(&self, window_id: WindowId) -> Result<&[SemanticsNode]>
pub fn window_title(&self, window_id: WindowId) -> Result<&str>
pub fn window_icon(&self, window_id: WindowId) -> Result<Option<&WindowIcon>>
pub fn window_ids(&self) -> Vec<WindowId>
pub fn needs_render(&self, window_id: WindowId) -> Result<bool>
pub fn schedule(&self, window_id: WindowId) -> Result<FrameSchedule>
pub fn focus_state(&self, window_id: WindowId) -> Result<FocusState>
pub fn focused_widget(&self, window_id: WindowId) -> Result<Option<WidgetId>>
pub fn pointer_capture_target( &self, window_id: WindowId, pointer_id: u64, ) -> Result<Option<WidgetId>>
Sourcepub fn window_initial_size(&self, window_id: WindowId) -> Result<Option<Size>>
pub fn window_initial_size(&self, window_id: WindowId) -> Result<Option<Size>>
Return the logical initial size requested by the window builder.
Sourcepub fn window_initial_position(
&self,
window_id: WindowId,
) -> Result<Option<Point>>
pub fn window_initial_position( &self, window_id: WindowId, ) -> Result<Option<Point>>
Return the physical desktop position requested by the window builder.
Sourcepub fn window_cursor_state(
&self,
window_id: WindowId,
) -> Result<WindowCursorState>
pub fn window_cursor_state( &self, window_id: WindowId, ) -> Result<WindowCursorState>
Return the desired cursor state for a host window.
Platform hosts should apply a newer revision promptly after event
dispatch so web pointer-lock requests remain inside the browser’s user
activation callback.
pub fn widget_graph(&self, window_id: WindowId) -> Result<WidgetGraphSnapshot>
Sourcepub fn set_inspector_tracing(
&mut self,
window_id: WindowId,
enabled: bool,
) -> Result<()>
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.
pub fn inspector_tracing(&self, window_id: WindowId) -> Result<bool>
Sourcepub fn inspector_snapshot(
&self,
window_id: WindowId,
) -> Result<WindowInspectorSnapshot>
pub fn inspector_snapshot( &self, window_id: WindowId, ) -> Result<WindowInspectorSnapshot>
Capture a unified renderer-neutral snapshot for debug tooling.
Sourcepub fn overlay_snapshot(
&self,
window_id: WindowId,
) -> Result<OverlayManagerSnapshot>
pub fn overlay_snapshot( &self, window_id: WindowId, ) -> Result<OverlayManagerSnapshot>
Inspect the window’s currently presented overlay stack.
Sourcepub fn take_overlay_traces(
&mut self,
window_id: WindowId,
) -> Result<Vec<OverlayTraceSample>>
pub fn take_overlay_traces( &mut self, window_id: WindowId, ) -> Result<Vec<OverlayTraceSample>>
Drain overlay lifecycle and dismissal diagnostics for an inspector.