Trait Var
pub trait Var: GodotConvert {
// Required methods
fn get_property(&self) -> Self::Via;
fn set_property(&mut self, value: Self::Via);
// Provided method
fn var_hint() -> PropertyHintInfo { ... }
}
Expand description
Trait implemented for types that can be used as #[var]
fields.
This creates a copy of the value, according to copy semantics provided by Clone
. For example, Array
, Dictionary
and Gd
are
returned by shared reference instead of copying the actual data.
This does not require FromGodot
or ToGodot
, so that something can be used as a property even if it can’t be used in function
arguments/return types.
See also Export
, a specialization of this trait for properties exported to the editor UI.
For enums, this trait can be derived using the #[derive(Var)]
macro.
Required Methods§
fn get_property(&self) -> Self::Via
fn set_property(&mut self, value: Self::Via)
Provided Methods§
fn var_hint() -> PropertyHintInfo
fn var_hint() -> PropertyHintInfo
Specific property hints, only override if they deviate from GodotType::property_info
, e.g. for enums/newtypes.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.