Struct godot::meta::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.