Module godot::obj::bounds

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:

  1. 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)].

  2. Memory is used to check the memory strategy of the static type.

    This is useful when you operate on associated functions of Gd<T> or T, e.g. for construction.

    • MemRefCounted is used for RefCounted classes and derived.
    • MemManual is used for Object and all inherited classes, which are not RefCounted (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§

Structs§

  • No memory management, user responsible for not leaking. This is used for all Object derivates, which are not RefCounted. 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.