pub struct BuildContext { /* private fields */ }Expand description
A scoped build context. Cloning a context keeps the same consumer identity;
BuildContext::for_consumer creates a distinct dependency owner.
Implementations§
Source§impl BuildContext
impl BuildContext
Sourcepub fn for_consumer(consumer: ConsumerId) -> Self
pub fn for_consumer(consumer: ConsumerId) -> Self
Creates an empty root context for a caller-owned consumer identity.
Creates another dependency owner that observes the same retained inherited environment and shares this context’s dependency tracker.
Sourcepub fn boundary_for_consumer(&self, consumer: ConsumerId) -> Self
pub fn boundary_for_consumer(&self, consumer: ConsumerId) -> Self
Creates an explicit inherited lookup boundary for another consumer. Values above this point are not visible, while dependency invalidation remains in the same retained-tree tracker.
Sourcepub const fn consumer_id(&self) -> ConsumerId
pub const fn consumer_id(&self) -> ConsumerId
Returns the identity used for dependency invalidation.
Sourcepub fn child(&self) -> Self
pub fn child(&self) -> Self
Creates a child environment. Values in the child shadow values in its parent while keeping the same dependency tracker and consumer.
Sourcepub fn provide<T: Any>(&self, value: T) -> Self
pub fn provide<T: Any>(&self, value: T) -> Self
Creates a child context with one inherited value.
Sourcepub fn insert<T: Any>(&self, value: T) -> bool
pub fn insert<T: Any>(&self, value: T) -> bool
Inserts or replaces a value in this environment. Existing consumers that watched this type are marked dirty when the value changes.
Sourcepub fn set<T: Any + PartialEq>(&self, value: T) -> bool
pub fn set<T: Any + PartialEq>(&self, value: T) -> bool
Replaces a value only when its PartialEq value changed.
pub fn contains<T: Any>(&self) -> bool
pub fn revision(&self) -> u64
Sourcepub fn read<T: Any + Clone>(&self) -> Option<T>
pub fn read<T: Any + Clone>(&self) -> Option<T>
Reads an inherited value without recording a dependency.
Reads an inherited value as shared ownership without recording a dependency.
Sourcepub fn depend<T: Any + Clone>(&self) -> Option<T>
pub fn depend<T: Any + Clone>(&self) -> Option<T>
Reads a value and records the environment lookup as a dependency.
Reads a shared inherited value while recording the dependency without cloning the value itself.
Sourcepub fn watch<T: Any + Clone>(&self) -> Option<T>
pub fn watch<T: Any + Clone>(&self) -> Option<T>
Alias for BuildContext::depend, matching reactive UI terminology.
Sourcepub fn enter(&self) -> ContextGuard
pub fn enter(&self) -> ContextGuard
Enters this context as the active build scope. Signal reads made while the guard is alive are associated with this context’s consumer.
Sourcepub fn scope(&self) -> ContextGuard
pub fn scope(&self) -> ContextGuard
Alias for BuildContext::enter.
Sourcepub fn build<R>(&self, callback: impl FnOnce(&BuildContext) -> R) -> R
pub fn build<R>(&self, callback: impl FnOnce(&BuildContext) -> R) -> R
Clears old dependencies, enters the build scope, and invokes the callback. This is the normal runtime integration point.
Sourcepub fn run<R>(&self, callback: impl FnOnce() -> R) -> R
pub fn run<R>(&self, callback: impl FnOnce() -> R) -> R
Runs a closure in a fresh dependency collection. Use BuildContext::build
when the callback needs the context as an argument.
Sourcepub fn with_context<R>(&self, callback: impl FnOnce(&BuildContext) -> R) -> R
pub fn with_context<R>(&self, callback: impl FnOnce(&BuildContext) -> R) -> R
Alias for BuildContext::build.
pub fn clear_dependencies(&self)
pub fn dependency_count(&self) -> usize
pub fn is_dirty(&self) -> bool
Sourcepub fn take_dirty(&self) -> bool
pub fn take_dirty(&self) -> bool
Takes and clears this consumer’s invalidation bit.
pub fn dependencies(&self) -> DependencySnapshot
Trait Implementations§
Source§impl Clone for BuildContext
impl Clone for BuildContext
Source§impl Debug for BuildContext
impl Debug for BuildContext
Auto Trait Implementations§
impl !RefUnwindSafe for BuildContext
impl !Send for BuildContext
impl !Sync for BuildContext
impl !UnwindSafe for BuildContext
impl Forget 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
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, 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> 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