Trait ToGodot
pub trait ToGodot: Sized + GodotConvert {
type ToVia<'v>: GodotType
where Self: 'v;
// Required method
fn to_godot(&self) -> Self::ToVia<'_>;
// Provided method
fn to_variant(&self) -> Variant { ... }
}
Expand description
Defines the canonical conversion to Godot for a type.
It is assumed that all the methods return equal values given equal inputs. Additionally, it is assumed
that if FromGodot
is implemented, converting to Godot and back again will return a value equal to the
starting value.
Violating these assumptions is safe but will give unexpected results.
Please read the godot::meta
module docs for further information about conversions.
Required Associated Types§
type ToVia<'v>: GodotType
where
Self: 'v
type ToVia<'v>: GodotType where Self: 'v
Target type of to_godot()
, which can differ from Via
for pass-by-reference types.
Note that currently, this only differs from Via
when Self
is RefArg<'r, T>
, which is
used inside generated code of engine methods. Other uses of to_godot()
, such as return types in #[func]
, still use value types.
This may change in future versions.
See also AsArg<T>
used as the “front-end” in Godot API parameters.
Required Methods§
Provided Methods§
fn to_variant(&self) -> Variant
fn to_variant(&self) -> Variant
Converts this type to a Variant.
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.