Struct pax_runtime_api::properties::Property

source ·
pub struct Property<T> { /* private fields */ }
Expand description

A typed wrapper over a UntypedProperty that casts to/from an untyped property on get/set

Implementations§

source§

impl<T: PropertyValue> Property<T>

source

pub fn new(val: T) -> Self

source

pub fn computed( evaluator: impl Fn() -> T + 'static, dependents: &[UntypedProperty] ) -> Self

source

pub fn new_with_name(val: T, name: &str) -> Self

source

pub fn computed_with_name( evaluator: impl Fn() -> T + 'static, dependents: &[UntypedProperty], name: &str ) -> Self

source

pub fn ease_to(&self, end_val: T, time: u64, curve: EasingCurve)

source

pub fn ease_to_later(&self, end_val: T, time: u64, curve: EasingCurve)

source

pub fn get(&self) -> T

Gets the currently stored value. Might be computationally expensive in a large reactivity network since this triggers re-evaluation of dirty property chains

source

pub fn set(&self, val: T)

Sets this properties value and sets the drity bit recursively of all of it’s dependencies if not already set

source

pub fn update(&self, f: impl FnOnce(&mut T))

source

pub fn read<V>(&self, f: impl FnOnce(&T) -> V) -> V

source

pub fn replace_with(&self, target: Property<T>)

replaces a properties evaluation/inbounds/value to be the same as target, while keeping it’s dependents. WARNING: this method can introduce circular dependencies if one is not careful. Using it wrongly can introduce memory leaks and inconsistent property behaviour. This method can be used to replace an inner value from for example a literal to a computed computed, while keeping the link to it’s dependents

source

pub fn untyped(&self) -> UntypedProperty

Casts this property to it’s untyped version

Trait Implementations§

source§

impl<T: Clone> Clone for Property<T>

source§

fn clone(&self) -> Property<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Property<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: PropertyValue> Default for Property<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de, T: PropertyValue + Deserialize<'de>> Deserialize<'de> for Property<T>

Serialization and deserialization fully disconnects properties, and only loads them back in as literals.

source§

fn deserialize<D>(deserializer: D) -> Result<Property<T>, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T: PropertyValue> Interpolatable for Property<T>

source§

fn interpolate(&self, other: &Self, t: f64) -> Self

source§

impl<T: PropertyValue + Serialize> Serialize for Property<T>

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Property<T>

§

impl<T> RefUnwindSafe for Property<T>
where T: RefUnwindSafe,

§

impl<T> Send for Property<T>
where T: Send,

§

impl<T> Sync for Property<T>
where T: Sync,

§

impl<T> Unpin for Property<T>
where T: Unpin,

§

impl<T> UnwindSafe for Property<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> RoundFrom<T> for T

source§

fn round_from(x: T) -> T

Performs the conversion.
source§

impl<T, U> RoundInto<U> for T
where U: RoundFrom<T>,

source§

fn round_into(self) -> U

Performs the conversion.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> PropertyValue for T
where T: Default + Clone + Interpolatable + 'static,