Expand description
Different ways how bounds of a GodotClass
can be checked.
This module contains multiple traits that can be used to check the characteristics of a GodotClass
type:
-
Declarer
tells you whether the class is provided by the engine or user-defined.DeclEngine
is used for all classes provided by the engine (e.g.Node3D
).DeclUser
is used for all classes defined by the user, typically through#[derive(GodotClass)]
.
-
Memory
is used to check the memory strategy of the static type.This is useful when you operate on associated functions of
Gd<T>
orT
, e.g. for construction.MemRefCounted
is used forRefCounted
classes and derived.MemManual
is used forObject
and all inherited classes, which are notRefCounted
(e.g.Node
).
§Example
Declare a custom smart pointer which wraps Gd<T>
pointers, but only accepts T
objects that are manually managed.
use godot::prelude::*;
use godot::obj::{bounds, Bounds};
struct MyGd<T>
where T: GodotClass + Bounds<Memory = bounds::MemManual>
{
inner: Gd<T>,
}
Macros§
- Implements
Bounds
for a user-defined class.
Structs§
- No memory management, user responsible for not leaking. This is used for all
Object
derivates, which are notRefCounted
.Object
itself is also excluded. - Memory managed through Godot reference counter (always present). This is used for
RefCounted
classes and derived.
Enums§
- Expresses that a class is declared by the Godot engine.
- Expresses that a class is declared by the user.
Traits§
- Trait that specifies who declares a given
GodotClass
. - Specifies the memory strategy of the static type.