godot::meta

Struct PropertyInfo

pub struct PropertyInfo {
    pub variant_type: VariantType,
    pub class_name: ClassName,
    pub property_name: StringName,
    pub hint_info: PropertyHintInfo,
    pub usage: PropertyUsageFlags,
}
Expand description

Describes a property in Godot.

Abstraction of the low-level sys::GDExtensionPropertyInfo.

Keeps the actual allocated values (the sys equivalent only keeps pointers, which fall out of scope).

Fields§

§variant_type: VariantType

Which type this property has.

For objects this should be set to VariantType::OBJECT, and the class_name field to the actual name of the class.

For Variant, this should be set to VariantType::NIL.

§class_name: ClassName

Which class this property is.

This should be set to ClassName::none() unless the variant type is Object. You can use GodotClass::class_name() to get the right name to use here.

§property_name: StringName

The name of this property in Godot.

§hint_info: PropertyHintInfo

Additional type information for this property, e.g. about array types or enum values. Split into hint and hint_string members.

See also PropertyHint in the Godot docs.

§usage: PropertyUsageFlags

How this property should be used. See PropertyUsageFlags in Godot for the meaning.

Implementations§

§

impl PropertyInfo

pub fn new_var<T>(property_name: &str) -> PropertyInfo
where T: Var,

Create a new PropertyInfo representing a property named property_name with type T.

This will generate property info equivalent to what a #[var] attribute would.

pub fn new_export<T>(property_name: &str) -> PropertyInfo
where T: Export,

Create a new PropertyInfo representing an exported property named property_name with type T.

This will generate property info equivalent to what an #[export] attribute would.

pub fn with_hint_info(self, hint_info: PropertyHintInfo) -> PropertyInfo

Change the hint and hint_string to be the given hint_info.

See export_info_functions for functions that return appropriate PropertyHintInfos for various Godot annotations.

§Examples

Creating an @export_range property.

use godot::register::property::export_info_functions;
use godot::meta::PropertyInfo;

let property = PropertyInfo::new_export::<f64>("my_range_property")
    .with_hint_info(export_info_functions::export_range(
        0.0,
        10.0,
        Some(0.1),
        false,
        false,
        false,
        false,
        false,
        false,
        Some("mm".to_string()),
    ));

pub fn new_group(group_name: &str, group_prefix: &str) -> PropertyInfo

Create a new PropertyInfo representing a group in Godot.

See EditorInspector in Godot for more information.

pub fn new_subgroup(subgroup_name: &str, subgroup_prefix: &str) -> PropertyInfo

Create a new PropertyInfo representing a subgroup in Godot.

See EditorInspector in Godot for more information.

pub fn property_sys(&self) -> GDExtensionPropertyInfo

Converts to the FFI type. Keep this object allocated while using that!

pub fn empty_sys() -> GDExtensionPropertyInfo

Trait Implementations§

§

impl Clone for PropertyInfo

§

fn clone(&self) -> PropertyInfo

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for PropertyInfo

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, dst: *mut T)

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