Struct Variant

Source
pub struct Variant(/* private fields */);
Expand description

A Variant can represent many of godot’s core types.

The underlying data can be either stored inline or reference-counted, dependning on the size of the type and whether the it is trivially copyable.

Implementations§

Source§

impl Variant

Source

pub fn from_vector2(val: &TypedVector2D<f32, UnknownUnit>) -> Variant

Creates a Variant wrapping a Vector2.

Source

pub fn from_vector3(val: &TypedVector3D<f32, UnknownUnit>) -> Variant

Creates a Variant wrapping a Vector3.

Source

pub fn from_quat( val: &TypedRotation3D<f32, UnknownUnit, UnknownUnit>, ) -> Variant

Creates a Variant wrapping a Quat.

Source

pub fn from_plane(val: &Plane) -> Variant

Creates a Variant wrapping a Plane.

Source

pub fn from_rect2(val: &TypedRect<f32>) -> Variant

Creates a Variant wrapping a Rect2.

Source

pub fn from_transform(val: &Transform) -> Variant

Creates a Variant wrapping a Transform.

Source

pub fn from_transform2d( val: &TypedTransform2D<f32, UnknownUnit, UnknownUnit>, ) -> Variant

Creates a Variant wrapping a Transform2D.

Source

pub fn from_basis(val: &Basis) -> Variant

Creates a Variant wrapping a Basis.

Source

pub fn from_color(val: &Color) -> Variant

Creates a Variant wrapping a Color.

Source

pub fn from_aabb(val: &Aabb) -> Variant

Creates a Variant wrapping an Aabb.

Source

pub fn from_rid(val: &Rid) -> Variant

Creates a Variant wrapping an Rid.

Source

pub fn from_node_path(val: &NodePath) -> Variant

Creates a Variant wrapping a NodePath.

Source

pub fn from_godot_string(val: &GodotString) -> Variant

Creates a Variant wrapping a GodotString.

Source

pub fn from_array(val: &VariantArray) -> Variant

Creates an Variant wrapping an array of variants.

Source

pub fn from_byte_array(val: &ByteArray) -> Variant

Creates a Variant wrapping a byte array.

Source

pub fn from_int32_array(val: &Int32Array) -> Variant

Creates a Variant wrapping an array of 32bit signed integers.

Source

pub fn from_float32_array(val: &Float32Array) -> Variant

Creates a Variant wrapping an array of 32bit floats.

Source

pub fn from_string_array(val: &StringArray) -> Variant

Creates a Variant wrapping an array of godot strings.

Source

pub fn from_vector2_array(val: &Vector2Array) -> Variant

Creates a Variant wrapping an array of 2d vectors.

Source

pub fn from_vector3_array(val: &Vector3Array) -> Variant

Creates a Variant wrapping an array of 3d vectors.

Source

pub fn from_color_array(val: &ColorArray) -> Variant

Creates a Variant wrapping an array of colors.

Source

pub fn from_dictionary(val: &Dictionary) -> Variant

Creates a Variant wrapping a dictionary.

Source

pub fn new() -> Variant

Creates an empty Variant.

Source

pub fn from_str<S>(s: S) -> Variant
where S: AsRef<str>,

Creates a Variant wrapping a string.

Source

pub fn from_object<T>(val: &T) -> Variant
where T: GodotObject,

Creates a Variant wrapping a Godot object.

Source

pub fn from_i64(v: i64) -> Variant

Creates a Variant wrapping a signed integer value.

Source

pub fn from_u64(v: u64) -> Variant

Creates a Variant wrapping an unsigned integer value.

Source

pub fn from_bool(v: bool) -> Variant

Creates a Variant wrapping an boolean.

Source

pub fn to_vector2(&self) -> TypedVector2D<f32, UnknownUnit>

Do a best effort to create a Vector2 out of the variant, possibly returning a default value.

Source

pub fn try_to_vector2(&self) -> Option<TypedVector2D<f32, UnknownUnit>>

Returns Some(Vector2) if this variant is one, None otherwise.

Source

pub fn to_vector3(&self) -> TypedVector3D<f32, UnknownUnit>

Do a best effort to create a Vector3 out of the variant, possibly returning a default value.

Source

pub fn try_to_vector3(&self) -> Option<TypedVector3D<f32, UnknownUnit>>

Returns Some(Vector3) if this variant is one, None otherwise.

Source

pub fn to_quat(&self) -> TypedRotation3D<f32, UnknownUnit, UnknownUnit>

Do a best effort to create a Quat out of the variant, possibly returning a default value.

Source

pub fn try_to_quat( &self, ) -> Option<TypedRotation3D<f32, UnknownUnit, UnknownUnit>>

Returns Some(Quat) if this variant is one, None otherwise.

Source

pub fn to_plane(&self) -> Plane

Do a best effort to create a Plane out of the variant, possibly returning a default value.

Source

pub fn try_to_plane(&self) -> Option<Plane>

Returns Some(Plane) if this variant is one, None otherwise.

Source

pub fn to_rect2(&self) -> TypedRect<f32>

Do a best effort to create a Rect2 out of the variant, possibly returning a default value.

Source

pub fn try_to_rect2(&self) -> Option<TypedRect<f32>>

Returns Some(Rect2) if this variant is one, None otherwise.

Source

pub fn to_transform(&self) -> Transform

Do a best effort to create a Transform out of the variant, possibly returning a default value.

Source

pub fn try_to_transform(&self) -> Option<Transform>

Returns Some(Transform) if this variant is one, None otherwise.

Source

pub fn to_transform2d(&self) -> TypedTransform2D<f32, UnknownUnit, UnknownUnit>

Do a best effort to create a Transform2D out of the variant, possibly returning a default value.

Source

pub fn try_to_transform2d( &self, ) -> Option<TypedTransform2D<f32, UnknownUnit, UnknownUnit>>

Returns Some(Transform2D) if this variant is one, None otherwise.

Source

pub fn to_basis(&self) -> Basis

Do a best effort to create a Basis out of the variant, possibly returning a default value.

Source

pub fn try_to_basis(&self) -> Option<Basis>

Returns Some(Basis) if this variant is one, None otherwise.

Source

pub fn to_color(&self) -> Color

Do a best effort to create a Color out of the variant, possibly returning a default value.

Source

pub fn try_to_color(&self) -> Option<Color>

Returns Some(Color) if this variant is one, None otherwise.

Source

pub fn to_aabb(&self) -> Aabb

Do a best effort to create an Aabb out of the variant, possibly returning a default value.

Source

pub fn try_to_aabb(&self) -> Option<Aabb>

Returns Some(Aabb) if this variant is one, None otherwise.

Source

pub fn to_f64(&self) -> f64

Do a best effort to create a f64 out of the variant, possibly returning a default value.

Source

pub fn try_to_f64(&self) -> Option<f64>

Returns Some(f64) if this variant is one, None otherwise.

Source

pub fn to_i64(&self) -> i64

Do a best effort to create an i64 out of the variant, possibly returning a default value.

Source

pub fn try_to_i64(&self) -> Option<i64>

Returns Some(i64) if this variant is one, None otherwise.

Source

pub fn to_bool(&self) -> bool

Do a best effort to create a bool out of the variant, possibly returning a default value.

Source

pub fn try_to_bool(&self) -> Option<bool>

Returns Some(bool) if this variant is one, None otherwise.

Source

pub fn to_node_path(&self) -> NodePath

Do a best effort to create a NodePath out of the variant, possibly returning a default value.

Source

pub fn try_to_node_path(&self) -> Option<NodePath>

Returns Some(NodePath) if this variant is one, None otherwise.

Source

pub fn to_godot_string(&self) -> GodotString

Do a best effort to create a GodotString out of the variant, possibly returning a default value.

Source

pub fn try_to_godot_string(&self) -> Option<GodotString>

Returns Some(GodotString) if this variant is one, None otherwise.

Source

pub fn to_rid(&self) -> Rid

Do a best effort to create a Rid out of the variant, possibly returning a default value.

Source

pub fn try_to_rid(&self) -> Option<Rid>

Returns Some(Rid) if this variant is one, None otherwise.

Source

pub fn to_array(&self) -> VariantArray

Do a best effort to create a VariantArray out of the variant, possibly returning a default value.

Source

pub fn try_to_array(&self) -> Option<VariantArray>

Returns Some(VariantArray) if this variant is one, None otherwise.

Source

pub fn to_byte_array(&self) -> ByteArray

Do a best effort to create a ByteArray out of the variant, possibly returning a default value.

Source

pub fn try_to_byte_array(&self) -> Option<ByteArray>

Returns Some(ByteArray) if this variant is one, None otherwise.

Source

pub fn to_int32_array(&self) -> Int32Array

Do a best effort to create an Int32Array out of the variant, possibly returning a default value.

Source

pub fn try_to_int32_array(&self) -> Option<Int32Array>

Returns Some(Int32Array) if this variant is one, None otherwise.

Source

pub fn to_float32_array(&self) -> Float32Array

Do a best effort to create a Float32Array out of the variant, possibly returning a default value.

Source

pub fn try_to_float32_array(&self) -> Option<Float32Array>

Returns Some(Float32Array) if this variant is one, None otherwise.

Source

pub fn to_string_array(&self) -> StringArray

Do a best effort to create a StringArray out of the variant, possibly returning a default value.

Source

pub fn try_to_string_array(&self) -> Option<StringArray>

Returns Some(StringArray) if this variant is one, None otherwise.

Source

pub fn to_vector2_array(&self) -> Vector2Array

Do a best effort to create a Vector2Array out of the variant, possibly returning a default value.

Source

pub fn try_to_vector2_array(&self) -> Option<Vector2Array>

Returns Some(Vector2Array) if this variant is one, None otherwise.

Source

pub fn to_vector3_array(&self) -> Vector3Array

Do a best effort to create a Vector3Array out of the variant, possibly returning a default value.

Source

pub fn try_to_vector3_array(&self) -> Option<Vector3Array>

Returns Some(Vector3Array) if this variant is one, None otherwise.

Source

pub fn to_color_array(&self) -> ColorArray

Do a best effort to create a ColorArray out of the variant, possibly returning a default value.

Source

pub fn try_to_color_array(&self) -> Option<ColorArray>

Returns Some(ColorArray) if this variant is one, None otherwise.

Source

pub fn to_dictionary(&self) -> Dictionary

Do a best effort to create a Dictionary out of the variant, possibly returning a default value.

Source

pub fn try_to_dictionary(&self) -> Option<Dictionary>

Returns Some(Dictionary) if this variant is one, None otherwise.

Source

pub fn try_to_object<T>(&self) -> Option<T>
where T: GodotObject,

Source

pub fn to_string(&self) -> String

Source

pub fn try_to_string(&self) -> Option<String>

Source

pub fn get_type(&self) -> VariantType

Returns this variant’s type.

Source

pub fn is_nil(&self) -> bool

Returns true if this is an empty variant.

Source

pub fn has_method(&self, method: &GodotString) -> bool

Source

pub fn call(&mut self, method: &GodotString, args: &[Variant]) -> Result<(), ()>

Source

pub fn forget(self) -> godot_variant

Returns the internal ffi representation of the variant and consumes the rust object without running the destructor.

This should be only used when certain that the receiving side is responsible for running the destructor for the object, otherwise it is leaked.

Trait Implementations§

Source§

impl Clone for Variant

Source§

fn clone(&self) -> Variant

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

impl Debug for Variant

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Variant

Source§

fn default() -> Variant

Returns the “default value” for a type. Read more
Source§

impl Drop for Variant

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'l> From<&'l Aabb> for Variant

Source§

fn from(val: &'l Aabb) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l Basis> for Variant

Source§

fn from(val: &'l Basis) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l ByteArray> for Variant

Source§

fn from(val: &'l ByteArray) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l Color> for Variant

Source§

fn from(val: &'l Color) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l ColorArray> for Variant

Source§

fn from(val: &'l ColorArray) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l Dictionary> for Variant

Source§

fn from(val: &'l Dictionary) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l Float32Array> for Variant

Source§

fn from(val: &'l Float32Array) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l GodotString> for Variant

Source§

fn from(val: &'l GodotString) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l Int32Array> for Variant

Source§

fn from(val: &'l Int32Array) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l NodePath> for Variant

Source§

fn from(val: &'l NodePath) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l Plane> for Variant

Source§

fn from(val: &'l Plane) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l Rid> for Variant

Source§

fn from(val: &'l Rid) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l String> for Variant

Source§

fn from(val: &'l String) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l Transform> for Variant

Source§

fn from(val: &'l Transform) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l TypedRect<f32>> for Variant

Source§

fn from(val: &'l TypedRect<f32>) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l TypedRotation3D<f32, UnknownUnit, UnknownUnit>> for Variant

Source§

fn from(val: &'l TypedRotation3D<f32, UnknownUnit, UnknownUnit>) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l TypedTransform2D<f32, UnknownUnit, UnknownUnit>> for Variant

Source§

fn from(val: &'l TypedTransform2D<f32, UnknownUnit, UnknownUnit>) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l TypedVector2D<f32, UnknownUnit>> for Variant

Source§

fn from(val: &'l TypedVector2D<f32, UnknownUnit>) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l TypedVector3D<f32, UnknownUnit>> for Variant

Source§

fn from(val: &'l TypedVector3D<f32, UnknownUnit>) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l VariantArray> for Variant

Source§

fn from(val: &'l VariantArray) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l Vector2Array> for Variant

Source§

fn from(val: &'l Vector2Array) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l Vector3Array> for Variant

Source§

fn from(val: &'l Vector3Array) -> Variant

Converts to this type from the input type.
Source§

impl<'l> From<&'l str> for Variant

Source§

fn from(v: &str) -> Variant

Converts to this type from the input type.
Source§

impl<T> From<T> for Variant
where T: GodotObject,

Source§

fn from(val: T) -> Variant

Converts to this type from the input type.
Source§

impl From<bool> for Variant

Source§

fn from(val: bool) -> Variant

Converts to this type from the input type.
Source§

impl From<i64> for Variant

Source§

fn from(val: i64) -> Variant

Converts to this type from the input type.
Source§

impl From<u64> for Variant

Source§

fn from(val: u64) -> Variant

Converts to this type from the input type.
Source§

impl PartialEq for Variant

Source§

fn eq(&self, other: &Variant) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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, dest: *mut u8)

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