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§