Trait style::values::computed::ToComputedValue
source · pub trait ToComputedValue {
type ComputedValue;
// Required methods
fn to_computed_value(&self, context: &Context<'_>) -> Self::ComputedValue;
fn from_computed_value(computed: &Self::ComputedValue) -> Self;
}
Expand description
A trait to represent the conversion between computed and specified values.
This trait is derivable with #[derive(ToComputedValue)]
. The derived
implementation just calls ToComputedValue::to_computed_value
on each field
of the passed value. The deriving code assumes that if the type isn’t
generic, then the trait can be implemented as simple Clone::clone
calls,
this means that a manual implementation with ComputedValue = Self
is bogus
if it returns anything else than a clone.
Required Associated Types§
sourcetype ComputedValue
type ComputedValue
The computed value type we’re going to be converted to.
Required Methods§
sourcefn to_computed_value(&self, context: &Context<'_>) -> Self::ComputedValue
fn to_computed_value(&self, context: &Context<'_>) -> Self::ComputedValue
Convert a specified value to a computed value, using itself and the data
inside the Context
.
sourcefn from_computed_value(computed: &Self::ComputedValue) -> Self
fn from_computed_value(computed: &Self::ComputedValue) -> Self
Convert a computed value to specified value form.
This will be used for recascading during animation. Such from_computed_valued values should recompute to the same value.