Skip to content

Conversation

@Bromeon
Copy link
Member

@Bromeon Bromeon commented Oct 25, 2025

Implements godotengine/godot#86079 in Rust, enabling required parameters and return types.

GDExtension newly advertises information about parameters and return types in engine APIs, which are required, meaning non-null. In Rust, this means we can use Gd<T> instead of Option<Gd<T>>, improving type safety and unnecessary unwrapping.

The generated code looks as follows:

image image

The upstream PR is not yet merged, but you can test it as follows:

  • Check out latest commit of that PR (currently godotengine/godot@9ccb329).
  • Build Godot in dev/editor mode locally.
  • Set GODOT4_BIN environment variable to the Godot binary.
  • Check out this branch of godot-rust and compile, see below.

I gated this functionality behind a new feature experimental-required-objs, because it's still in flux, and every upstream change becomes breaking. Since I also refactored a few parts in related codegen, I will merge this soon, but the feature should leave existing usage unaffected.

Compilation:

# Integration tests
cargo build -p itest --features codegen-full-experimental,godot/api-custom,godot/experimental-required-objs
$GODOT4_BIN --headless --path itest/godot

# Unit tests
cargo test --features godot/api-custom,godot/experimental-required-objs

# RustDoc generation
cargo doc -p godot --features api-custom,experimental-required-objs,__codegen-full --no-deps --open

@Bromeon Bromeon added feature Adds functionality to the library c: engine Godot classes (nodes, resources, ...) labels Oct 25, 2025
@Bromeon Bromeon force-pushed the feature/required-object-apis branch from 7a1fb92 to e430cce Compare October 25, 2025 18:29
@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1383

@Bromeon Bromeon force-pushed the feature/required-object-apis branch from 765d2a7 to 096af2e Compare October 26, 2025 07:13
@Bromeon Bromeon enabled auto-merge October 26, 2025 07:16
@Bromeon Bromeon added this pull request to the merge queue Oct 26, 2025
Merged via the queue into master with commit 3a75a3b Oct 26, 2025
18 checks passed
@Bromeon Bromeon deleted the feature/required-object-apis branch October 26, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: engine Godot classes (nodes, resources, ...) feature Adds functionality to the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants