pub struct BuildContext { /* private fields */ }Expand description
Framework-controlled build scope for declarative roots. It intentionally exposes no element IDs or scheduler handles. Signals use the runtime’s scoped collector while a builder executes; reads outside a build simply return the current value and create no dependency.
Implementations§
Source§impl BuildContext
impl BuildContext
Sourcepub fn spawn<F, T>(&self, future: F) -> Task<T>
pub fn spawn<F, T>(&self, future: F) -> Task<T>
Spawns Tokio work owned by this declarative owner. Its output must be
Send; use Self::spawn_into to update UI-local state on completion.
pub fn spawn_in<F, T>(&self, scope: &TaskScope, future: F) -> Task<T>
Sourcepub fn spawn_into<F, T>(
&self,
future: F,
complete: impl FnOnce(Result<T, TaskFailure>, &mut Runtime) + 'static,
) -> TaskHandle
pub fn spawn_into<F, T>( &self, future: F, complete: impl FnOnce(Result<T, TaskFailure>, &mut Runtime) + 'static, ) -> TaskHandle
Starts owner-scoped Tokio work and handles the owned result on the UI
thread. The callback may safely capture an Incular Signal.
Sourcepub fn dispatch(&self, callback: impl FnOnce(&mut Runtime) + Send + 'static)
pub fn dispatch(&self, callback: impl FnOnce(&mut Runtime) + Send + 'static)
Queues a Send callback for the UI owner without granting any Tokio
worker mutable access to the widget/runtime tree.
pub fn spawn_blocking<T>(
&self,
work: impl FnOnce() -> T + Send + 'static,
complete: impl FnOnce(Result<T, TaskFailure>, &mut Runtime) + 'static,
) -> TaskHandlewhere
T: Send + 'static,
pub fn task_scope(&self) -> TaskScope
Sourcepub fn watch_focus_scope(&self, scope: &FocusScopeNode)
pub fn watch_focus_scope(&self, scope: &FocusScopeNode)
Makes the current retained builder depend on a focus scope.
A scope is an application-owned handle rather than a signal, so this explicit watch registers a weak, owner-lifetime subscription in the runtime’s ordinary reactive queue. The initial root build records the scope and installs the subscription once its element identity exists.
Sourcepub fn restoration_scope(&self) -> Option<RestorationScope>
pub fn restoration_scope(&self) -> Option<RestorationScope>
Returns the stable restoration scope for this build when the owning application explicitly enabled restoration. Ordinary applications have no restoration scope and therefore no persistence side effects.
Sourcepub fn restoration(&self) -> Option<RestorationHandle>
pub fn restoration(&self) -> Option<RestorationHandle>
Returns a callback-safe capability for reset, flush, and diagnostics when restoration is enabled. It contains no widget tree or native filesystem handle.
Sourcepub fn restorable<T>(
&self,
key: RestorationKey,
default: T,
) -> Option<Restorable<T>>
pub fn restorable<T>( &self, key: RestorationKey, default: T, ) -> Option<Restorable<T>>
Creates an opt-in reactive value under this build’s restoration scope.
key must be stable across reordering and rebuilds; use a separate
child scope for dynamic collections rather than an element position.
Sourcepub fn restored_signal<T>(
&self,
key: RestorationKey,
default: T,
) -> Option<Restorable<T>>
pub fn restored_signal<T>( &self, key: RestorationKey, default: T, ) -> Option<Restorable<T>>
Alias matching the common cx.restored_signal("count", 0) pattern.
The returned Restorable wraps a normal reactive signal; write via its
set/update methods so a mutation is captured for persistence.
Sourcepub fn open_window(
&self,
options: WindowOptions,
root: Widget,
) -> Result<WindowHandle, WindowError>
pub fn open_window( &self, options: WindowOptions, root: Widget, ) -> Result<WindowHandle, WindowError>
Queues another retained root for native creation. Its state, focus,
semantics, environment, compositor, and task scope are independent of
this context’s window; shared Signals may still be captured by the
supplied root and will subscribe each root independently.
Sourcepub fn window_opener(&self) -> Option<WindowOpener>
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.
Sourcepub fn window_handle(&self) -> Option<WindowHandle>
pub fn window_handle(&self) -> Option<WindowHandle>
Returns a command handle for the native window owning this build. Standalone/headless runtimes without an application window return None.
Sourcepub fn file_dialogs(&self) -> Option<FileDialogService>
pub fn file_dialogs(&self) -> Option<FileDialogService>
Returns the native file-dialog service owned by the current window. Standalone/headless runtimes without an application window return None.
Sourcepub fn global_shortcuts(&self) -> Option<GlobalShortcutService>
pub fn global_shortcuts(&self) -> Option<GlobalShortcutService>
Returns the application-scoped native global-shortcut service. Unlike
focused Shortcuts, registrations remain active while the application
is in the background and are identified independently of any window.
Sourcepub fn application_shell(&self) -> Option<ApplicationShellService>
pub fn application_shell(&self) -> Option<ApplicationShellService>
Returns application-scoped tray/status, notification, and taskbar/Dock services. The service contains no native handles and is callback-safe.
Sourcepub fn tokio_handle(&self) -> TokioHandle
pub fn tokio_handle(&self) -> TokioHandle
Returns the Tokio handle for advanced integrations. Tasks spawned
directly through it are not owner-scoped; prefer Self::spawn or
Self::spawn_into for UI work.
Sourcepub fn environment(&self) -> RuntimeEnvironment
pub fn environment(&self) -> RuntimeEnvironment
Reads all environment fields. Prefer the typed accessors below when a build uses only one value, so unrelated changes do not rebuild it.
pub fn viewport(&self) -> Size
pub fn scale_factor(&self) -> f64
pub fn text_scale(&self) -> f32
pub fn safe_insets(&self) -> EdgeInsets
pub fn view_insets(&self) -> EdgeInsets
Sourcepub fn view_padding(&self) -> EdgeInsets
pub fn view_padding(&self) -> EdgeInsets
Persistent system-obstruction margin, independent of transient
occlusion. Maintained SafeArea bottom edges read this alongside
the safe margin.
Sourcepub fn safe_area(&self, safe_area: SafeArea) -> Widget
pub fn safe_area(&self, safe_area: SafeArea) -> Widget
Resolves SafeArea from the authoritative logical insets while
recording only the dependencies it reads: the safe margin always,
plus the persistent view padding when the descriptor maintains its
bottom edge. This applies the same policy as retained
construction; transient occlusion never participates.
pub fn brightness(&self) -> Brightness
pub fn locales(&self) -> Vec<Locale>
Sourcepub fn resolve_locale(&self, supported: &[Locale]) -> Option<Locale>
pub fn resolve_locale(&self, supported: &[Locale]) -> Option<Locale>
Resolves a supported application locale while recording a locale-only dependency, so platform locale changes rebuild only consumers of it.
pub fn text_direction(&self) -> TextDirection
pub fn window_focused(&self) -> bool
pub fn reduced_motion(&self) -> bool
pub fn high_contrast(&self) -> bool
pub fn input_capabilities(&self) -> InputCapabilities
pub fn window_occluded(&self) -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for BuildContext
impl !Send for BuildContext
impl !Sync for BuildContext
impl !UnwindSafe for BuildContext
impl Freeze for BuildContext
impl Unpin for BuildContext
impl UnsafeUnpin for BuildContext
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
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) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
Source§type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
Source§fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T, C> ComponentsInto<C> for T
impl<T, C> ComponentsInto<C> for T
Source§fn components_into(self) -> C
fn components_into(self) -> C
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.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, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more