Struct muse_ui::DynamicValue
source · pub struct DynamicValue(pub Dynamic<Value>);Tuple Fields§
§0: Dynamic<Value>Methods from Deref<Target = Dynamic<Value>>§
pub fn downgrade(&self) -> WeakDynamic<T>
pub fn downgrade(&self) -> WeakDynamic<T>
pub fn instances(&self) -> usize
pub fn instances(&self) -> usize
Returns the number [Dynamic]s that point to this same value.
The returned count includes self.
§Panics
This function panics if this value is already locked by the current thread.
pub fn readers(&self) -> usize
pub fn readers(&self) -> usize
Returns the number of [DynamicReader]s for this value.
§Panics
This function panics if this value is already locked by the current thread.
pub fn linked<R, TIntoR, TIntoRResult, RIntoT, RIntoTResult>(
&self,
t_into_r: TIntoR,
r_into_t: RIntoT,
) -> Dynamic<R>
pub fn linked<R, TIntoR, TIntoRResult, RIntoT, RIntoTResult>( &self, t_into_r: TIntoR, r_into_t: RIntoT, ) -> Dynamic<R>
Returns a new dynamic that has its contents linked with self by the
pair of mapping functions provided.
When the returned dynamic is updated, r_into_t will be invoked. This
function accepts &R and can return T, or Option<T>. If a value is
produced, self will be updated with the new value.
When self is updated, t_into_r will be invoked. This function
accepts &T and can return R or Option<R>. If a value is produced,
the returned dynamic will be updated with the new value.
§Panics
This function panics if calling t_into_r with the current contents of
the Dynamic produces a None value. This requirement is only for the
first invocation, and it is guaranteed to occur before this function
returns.
pub fn linked_string(&self) -> Dynamic<String>
pub fn linked_string(&self) -> Dynamic<String>
Creates a linked dynamic containing a String.
When self is updated, ToString::to_string() will be called to
produce a new string value to store in the returned dynamic.
When the returned dynamic is updated, str::parse is called
to produce a new T. If an error is returned, self will not be
updated. Otherwise, self will be updated with the produced value.
pub fn set_source(&self, source: CallbackHandle)
pub fn set_source(&self, source: CallbackHandle)
Sets the current source for this dynamic with source.
A dynamic can have multiple source callbacks.
This ensures that source stays active as long as any clones of self
are alive.
pub fn with_clone<R>(&self, with_clone: impl FnOnce(Dynamic<T>) -> R) -> R
pub fn with_clone<R>(&self, with_clone: impl FnOnce(Dynamic<T>) -> R) -> R
A helper function that invokes with_clone with a clone of self. This
code may produce slightly more readable code.
use cushy::value::{Dynamic, Source};
let value = Dynamic::new(1);
// Using with_clone
value.with_clone(|value| {
std::thread::spawn(move || {
println!("{}", value.get());
})
});
// Using an explicit clone
std::thread::spawn({
let value = value.clone();
move || {
println!("{}", value.get());
}
});
println!("{}", value.get());pub fn create_reader(&self) -> DynamicReader<T>
pub fn create_reader(&self) -> DynamicReader<T>
Returns a new reference-based reader for this dynamic value.
§Panics
This function panics if this value is already locked by the current thread.
pub fn lock(&self) -> DynamicGuard<'_, T>
pub fn lock(&self) -> DynamicGuard<'_, T>
Returns an exclusive reference to the contents of this dynamic.
This call will block until all other guards for this dynamic have been dropped.
§Panics
This function panics if this value is already locked by the current thread.
pub fn try_lock(&self) -> Result<DynamicGuard<'_, T>, DeadlockError>
pub fn try_lock(&self) -> Result<DynamicGuard<'_, T>, DeadlockError>
Returns an exclusive reference to the contents of this dynamic.
This call will block until all other guards for this dynamic have been dropped.
§Errors
Returns an error if the current thread already holds a lock to this dynamic.
pub fn transition_to(&self, new_value: T) -> DynamicTransition<T>
pub fn transition_to(&self, new_value: T) -> DynamicTransition<T>
Returns a pending transition for this value to new_value.
pub fn new_radio(&self, widget_value: T, label: impl MakeWidget) -> Radio<T>
pub fn new_radio(&self, widget_value: T, label: impl MakeWidget) -> Radio<T>
Returns a new [Radio] that updates this dynamic to widget_value when
pressed. label is drawn next to the checkbox and is also clickable to
select the radio.
pub fn new_select(&self, widget_value: T, label: impl MakeWidget) -> Select<T>
pub fn new_select(&self, widget_value: T, label: impl MakeWidget) -> Select<T>
Returns a new [Select] that updates this dynamic to widget_value
when pressed. label is drawn next to the checkbox and is also
clickable to select the widget.
pub fn validate_with<E, Valid>(&self, check: Valid) -> Dynamic<Validation>
pub fn validate_with<E, Valid>(&self, check: Valid) -> Dynamic<Validation>
Validates the contents of this dynamic using the check function,
returning a dynamic that contains the validation status.
pub fn to_switcher(&self) -> Switcher
pub fn to_switcher(&self) -> Switcher
Returns a new [Switcher] widget whose contents is the value of this
dynamic.
pub fn to_rows(&self) -> Stack
pub fn to_rows(&self) -> Stack
Returns self as a vertical [Stack] of rows.
pub fn to_columns(&self) -> Stack
pub fn to_columns(&self) -> Stack
Returns self as a horizontal [Stack] of columns.
pub fn to_layers(&self) -> Layers
pub fn to_layers(&self) -> Layers
Returns self as [Layers], with the widgets being stacked in the Z
direction.
pub fn to_wrap(&self) -> Wrap
pub fn to_wrap(&self) -> Wrap
Returns a [Wrap] that lays the children out horizontally, wrapping
into additional rows as needed.
Trait Implementations§
source§impl Clone for DynamicValue
impl Clone for DynamicValue
source§fn clone(&self) -> DynamicValue
fn clone(&self) -> DynamicValue
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl CustomType for DynamicValue
impl CustomType for DynamicValue
source§impl Debug for DynamicValue
impl Debug for DynamicValue
source§impl Deref for DynamicValue
impl Deref for DynamicValue
source§impl DerefMut for DynamicValue
impl DerefMut for DynamicValue
source§impl PartialEq for DynamicValue
impl PartialEq for DynamicValue
source§impl Trace for DynamicValue
impl Trace for DynamicValue
impl StructuralPartialEq for DynamicValue
Auto Trait Implementations§
impl Freeze for DynamicValue
impl !RefUnwindSafe for DynamicValue
impl Send for DynamicValue
impl Sync for DynamicValue
impl Unpin for DynamicValue
impl !UnwindSafe for DynamicValue
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>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
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>,
§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.§impl<A> Cast for A
impl<A> Cast for A
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> DynamicValue for Twhere
T: CustomType,
impl<T> DynamicValue for Twhere
T: CustomType,
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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>,
§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 more§impl<T> IntoReadOnly<T> for T
impl<T> IntoReadOnly<T> for T
§fn into_read_only(self) -> ReadOnly<T>
fn into_read_only(self) -> ReadOnly<T>
self as a ReadOnly.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.§impl<T> IntoValue<Option<T>> for T
impl<T> IntoValue<Option<T>> for T
§fn into_value(self) -> Value<Option<T>>
fn into_value(self) -> Value<Option<T>>
Value].§impl<T> IntoValue<T> for T
impl<T> IntoValue<T> for T
§fn into_value(self) -> Value<T>
fn into_value(self) -> Value<T>
Value].§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
§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