Struct 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 new_from_untyped(untyped: UntypedProperty) -> 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 dirty bit recursively of all of its 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 its dependents. WARNING: this method can introduce circular dependencies if one is not careful. Using it wrongly can introduce memory leaks and inconsistent property behavior. This method can be used to replace an inner value from for example a literal to a computed computed, while keeping the link to its dependents

Source

pub fn untyped(&self) -> UntypedProperty

Casts this property to its untyped version

Trait Implementations§

Source§

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

Source§

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

Returns a duplicate 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: PropertyValue + 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
Source§

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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,