pub struct InheritableVariable<T> { /* private fields */ }
Expand description

A wrapper for a variable that hold additional flag that tells that initial value was changed in runtime.

InheritableVariables are used for resource inheritance system. Resource inheritance may just sound weird, but the idea behind it is very simple - take property values from parent resource if the value in current hasn’t changed in runtime.

To get better understanding, let’s look at very simple example. Imagine you have a scene with a 3d model instance. Now you realizes that the 3d model has a misplaced object and you need to fix it, you open a 3D modelling software (Blender, 3Ds max, etc) and move the object to a correct spot and re-save the 3D model. The question is: what should happen with the instance of the object in the scene? Logical answer would be: if it hasn’t been modified, then just take the new position from the 3D model. This is where inheritable variable comes into play. If you’ve change the value of such variable, it will remember changes and the object will stay on its new position instead of changed.

Deref and DerefMut

Access via Deref provides access to inner variable. DerefMut marks variable as modified and returns a mutable reference to inner variable.

Implementations§

Clones wrapped value.

Tries to sync a value in a data model with a value in the inheritable variable. The value will be synced only if it was marked as needs sync.

Creates new non-modified variable from given value.

Creates new variable from given value and marks it with VariableFlags::MODIFIED flag.

Creates new variable from a given value with custom flags.

Replaces value and also raises the VariableFlags::MODIFIED flag.

Replaces value and flags.

Replaces current value without marking the variable modified.

Returns true if the respective data model’s variable must be synced.

Returns a reference to the wrapped value.

Returns a mutable reference to the wrapped value.

Important notes.

The method raises modified flag, no matter if actual modification was made!

Returns a mutable reference to the wrapped value.

Important notes.

This method does not mark the value as modified!

Returns true if variable was modified and should not be overwritten during property inheritance.

Marks value as modified, so its value won’t be overwritten during property inheritance.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Calls user method specified with #[reflect(setter = ..)] or falls back to Reflect::field_mut
Tries to inherit a value from parent. It will succeed only if the current variable is not marked as modified.
Resets modified flag from the variable.
Returns current variable flags.
Returns true if value was modified.
Returns true if value equals to other’s value.
Clones self value.
Marks value as modified, so its value won’t be overwritten during property inheritance.
Returns a mutable reference to wrapped value without marking the variable itself as modified.
Returns a shared reference to wrapped value without marking the variable itself as modified.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Casts self to a &dyn Any
Converts to this type from the input type.

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.