Trait Var

Source
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§

Source

fn get_property(&self) -> Self::Via

Source

fn set_property(&mut self, value: Self::Via)

Provided Methods§

Source

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.

Implementations on Foreign Types§

Source§

impl Var for bool

Source§

fn get_property(&self) -> <bool as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <bool as GodotConvert>::Via)

Source§

impl Var for f32

Source§

fn get_property(&self) -> <f32 as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <f32 as GodotConvert>::Via)

Source§

impl Var for f64

Source§

fn get_property(&self) -> <f64 as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <f64 as GodotConvert>::Via)

Source§

impl Var for i8

Source§

fn get_property(&self) -> <i8 as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <i8 as GodotConvert>::Via)

Source§

impl Var for i16

Source§

fn get_property(&self) -> <i16 as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <i16 as GodotConvert>::Via)

Source§

impl Var for i32

Source§

fn get_property(&self) -> <i32 as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <i32 as GodotConvert>::Via)

Source§

impl Var for i64

Source§

fn get_property(&self) -> <i64 as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <i64 as GodotConvert>::Via)

Source§

impl Var for u8

Source§

fn get_property(&self) -> <u8 as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <u8 as GodotConvert>::Via)

Source§

impl Var for u16

Source§

fn get_property(&self) -> <u16 as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <u16 as GodotConvert>::Via)

Source§

impl Var for u32

Source§

fn get_property(&self) -> <u32 as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <u32 as GodotConvert>::Via)

Source§

impl<T> Var for Option<T>
where T: Var + FromGodot, Option<T>: GodotConvert<Via = Option<<T as GodotConvert>::Via>>,

Source§

fn get_property(&self) -> <Option<T> as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <Option<T> as GodotConvert>::Via)

Implementors§

Source§

impl Var for Rid

Source§

impl Var for Aabb

Source§

impl Var for Basis

Source§

impl Var for Callable

Source§

impl Var for Color

Source§

impl Var for Dictionary

Source§

impl Var for GString

Source§

impl Var for NodePath

Source§

impl Var for PackedByteArray

Source§

impl Var for PackedColorArray

Source§

impl Var for PackedFloat32Array

Source§

impl Var for PackedFloat64Array

Source§

impl Var for PackedInt32Array

Source§

impl Var for PackedInt64Array

Source§

impl Var for PackedStringArray

Source§

impl Var for PackedVector2Array

Source§

impl Var for PackedVector3Array

Source§

impl Var for PackedVector4Array

Source§

impl Var for Plane

Source§

impl Var for Projection

Source§

impl Var for Quaternion

Source§

impl Var for Rect2

Source§

impl Var for Rect2i

Source§

impl Var for Signal

Source§

impl Var for StringName

Source§

impl Var for Transform2D

Source§

impl Var for Transform3D

Source§

impl Var for Variant

Source§

impl Var for Vector2

Source§

impl Var for Vector2i

Source§

impl Var for Vector3

Source§

impl Var for Vector3i

Source§

impl Var for Vector4

Source§

impl Var for Vector4i

Source§

impl<T> Var for Array<T>
where T: ArrayElement,

Source§

impl<T> Var for Gd<T>
where T: GodotClass,

Source§

impl<T> Var for OnEditor<Gd<T>>
where T: GodotClass,

Source§

impl<T> Var for OnEditor<T>

Source§

impl<T> Var for OnReady<T>
where T: Var,

Source§

impl<T, D> Var for DynGd<T, D>
where T: GodotClass, D: 'static + ?Sized,

Source§

impl<T, D> Var for OnEditor<DynGd<T, D>>
where T: GodotClass, D: 'static + ?Sized,