[][src]Crate gdnative_core

Rust bindings for the Godot game engine

This crate contains high-level wrappers around the Godot game engine's gdnaive API. Some of the types were automatically generated from the engine's JSON API description, and some other types are hand made wrappers around the core C types.

Memory management

Reference counting

A lot of the types provided by the engine are internally reference counted and allow mutable aliasing. In rust parlance this means that a type such as gdnative::ConcavePolygonShape2D is functionally equivalent to a Rc<Cell<Something>> rather than Rc<Something>.

Since it is easy to expect containers and other types to allocate a copy of their content when using the Clone trait, most of these types do not implement Clone and instead provide a new_ref(&self) -> Self method to create references to the same collection or object.

Manually managed objects

Some types are manually managed. This means that ownership can be passed to the engine or the object must be carefully deallocated using the object's free method.

Re-exports

pub use crate::geom::*;
pub use crate::user_data::Map;
pub use crate::user_data::MapMut;
pub use crate::user_data::UserData;

Modules

access

Maybe unaligned pool array access

geom

Geometric types.

init

Types and functionalities to declare and initialize gdnative classes.

user_data

Customizable user-data wrappers.

Macros

godot_dbg

Prints and returns the value of a given expression for quick and dirty debugging, using the engine's logging system (visible in the editor).

godot_error

Print an error using the engine's logging system (visible in the editor).

godot_gdnative_init

Declare the API endpoint to initialize the gdnative API on startup.

godot_gdnative_terminate

Declare the API endpoint invoked during shutdown.

godot_nativescript_init

Declare the API endpoint to initialize nativescript classes on startup.

godot_print

Print a message using the engine's logging system (visible in the editor).

godot_warn

Print a warning using the engine's logging system (visible in the editor).

godot_wrap_constructor

Convenience macro to wrap an object's constructor into a function pointer that can be passed to the engine when registering a class.

godot_wrap_destructor

Convenience macro to wrap an object's destructor into a function pointer that can be passed to the engine when registering a class.

godot_wrap_method

Convenience macro to wrap an object's method into a function pointer that can be passed to the engine when registering a class.

Structs

ByteArray

A reference-counted vector of bytes that uses Godot's pool allocator.

Color

RGBA color with 32 bits floating point components.

ColorArray

A reference-counted vector of ColorArray that uses Godot's pool allocator.

Dictionary

A reference-counted Dictionary of Variant key-value pairs.

Float32Array

A reference-counted vector of f32 that uses Godot's pool allocator.

FreeOnDrop

A wrapper that automatically frees the object when dropped.

GodotApi
GodotString

Godot's reference-counted string type.

Instance

A reference to a GodotObject with a rust NativeClass attached.

Int32Array

A reference-counted vector of i32 that uses Godot's pool allocator.

Iter
IterMut
MaybeNot

Wrapper type around a FromVariant result that may not be a success

NodePath

A reference-counted relative or absolute path in a scene tree, for use with Node.get_node() and similar functions. It can reference a node, a resource within a node, or a property of a node or resource.

Object

The base class of most Godot classes.

QueueFreeOnDrop

A wrapper that automatically enqueues the object for deletion when dropped.

Reference

Base class of all reference-counted types. Inherits Object.

Rid

The RID type is used to access the unique integer ID of a resource. They are opaque, so they do not grant access to the associated resource by themselves.

StringArray

A vector of GodotString that uses Godot's pool allocator.

StringName
Variant

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

VariantArray

A reference-counted Variant vector. Godot's generic array data type. Negative indices can be used to count from the right.

Vector2Array

A reference-counted vector of Vector2 that uses Godot's pool allocator.

Vector3Array

A reference-counted vector of Vector3 that uses Godot's pool allocator.

Enums

CallError
FromVariantError

Error type returned by FromVariant::from_variant.

GodotError
ObjectConnectFlags
VariantEnumRepr
VariantOperator
VariantStructRepr
VariantType
Vector3Axis

Traits

Free

Manually managed Godot classes implementing free.

FromVariant

Types that can be converted from a Variant.

GodotObject

Internal details.

Instanciable

GodotObjects that have a zero argument constructor.

NativeClass

Trait used for describing and initializing a Godot script class.

NativeClassMethods

Trait used to provide information of Godot-exposed methods of a script class.

Point2Godot

Helper methods for Point2.

QueueFree

Manually managed Godot classes implementing queue_free.

ToVariant

Types that can be converted to a Variant.

Vector2Godot

Helper methods for Vector2.

Functions

result_from_sys

Type Definitions

GodotResult