Skip to content

Commit 2406372

Browse files
committed
Move RpcConfig from godot::meta -> godot::register
1 parent b3086b5 commit 2406372

File tree

8 files changed

+26
-8
lines changed

8 files changed

+26
-8
lines changed

godot-codegen/src/special_cases/special_cases.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ pub fn maybe_rename_virtual_method(rust_method_name: &str) -> &str {
366366
}
367367
}
368368

369+
// TODO method-level extra docs, for:
370+
// - Node::rpc_config() -> link to RpcConfig.
371+
369372
pub fn get_class_extra_docs(class_name: &TyName) -> Option<&'static str> {
370373
match class_name.godot_ty.as_str() {
371374
"FileAccess" => {

godot-core/src/meta/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ mod class_name;
4949
mod godot_convert;
5050
mod method_info;
5151
mod property_info;
52-
// RpcConfig uses MultiplayerPeer::TransferMode and MultiplayerApi::RpcMode, which are only enabled in `codegen-full` feature.
53-
#[cfg(feature = "codegen-full")]
54-
mod rpc_config;
5552
mod sealed;
5653
mod signature;
5754
mod traits;
@@ -61,8 +58,6 @@ pub mod error;
6158
pub use args::*;
6259
pub use class_name::ClassName;
6360
pub use godot_convert::{FromGodot, GodotConvert, ToGodot};
64-
#[cfg(feature = "codegen-full")]
65-
pub use rpc_config::RpcConfig;
6661
pub use traits::{ArrayElement, GodotType, PackedArrayElement};
6762

6863
pub(crate) use array_type_info::ArrayTypeInfo;

godot-core/src/registry/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
*/
77

8-
// Note: final re-exports from godot-core are in lib.rs, mod private_register.
8+
// Note: final re-exports from godot-core are in lib.rs, mod register::private.
99
// These are public here for simplicity, but many are not imported by the main crate.
1010

1111
pub mod callbacks;
@@ -15,5 +15,11 @@ pub mod method;
1515
pub mod plugin;
1616
pub mod property;
1717

18+
// RpcConfig uses MultiplayerPeer::TransferMode and MultiplayerApi::RpcMode, which are only enabled in `codegen-full` feature.
19+
#[cfg(feature = "codegen-full")]
20+
mod rpc_config;
21+
#[cfg(feature = "codegen-full")]
22+
pub use rpc_config::RpcConfig;
23+
1824
#[doc(hidden)]
1925
pub mod godot_register_wrappers;

godot-macros/src/class/data_models/rpc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub enum RpcAttr {
1919
call_local: Option<bool>,
2020
channel: Option<u32>,
2121
},
22+
2223
// `args` key in the `rpc` attribute.
2324
// Example:
2425
// const RPC_CFG: RpcConfig = RpcConfig { mode: RpcMode::Authority, ..RpcConfig::default() };
@@ -76,7 +77,7 @@ pub fn make_rpc_registrations_fn(class_name: &Ident, funcs: &[FuncDefinition]) -
7677
#[allow(clippy::needless_update)] // clippy complains about using `..RpcConfig::default()` if all fields are overridden
7778
fn __register_rpcs(object: &mut dyn ::std::any::Any) {
7879
use ::std::any::Any;
79-
use ::godot::meta::RpcConfig;
80+
use ::godot::register::RpcConfig;
8081
use ::godot::classes::multiplayer_api::RpcMode;
8182
use ::godot::classes::multiplayer_peer::TransferMode;
8283
use ::godot::classes::Node;

godot-macros/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ pub fn derive_godot_class(input: TokenStream) -> TokenStream {
518518
/// - [User-defined functions](#user-defined-functions)
519519
/// - [Associated functions and methods](#associated-functions-and-methods)
520520
/// - [Virtual methods](#virtual-methods)
521+
/// - [RPC attributes](#rpc-attributes)
521522
/// - [Constants and signals](#signals)
522523
///
523524
/// # Constructors
@@ -676,6 +677,13 @@ pub fn derive_godot_class(input: TokenStream) -> TokenStream {
676677
///
677678
/// Make sure you understand the limitations in the [tutorial](https://godot-rust.github.io/book/register/virtual-functions.html).
678679
///
680+
/// ## RPC attributes
681+
///
682+
/// You can use the `#[rpc]` attribute to let your functions act as remote procedure calls (RPCs) in Godot. This is the Rust equivalent of
683+
/// GDScript's [`@rpc` annotation](https://docs.godotengine.org/en/stable/tutorials/networking/high_level_multiplayer.html#remote-procedure-calls).
684+
///
685+
///
686+
///
679687
/// # Constants and signals
680688
///
681689
/// Please refer to [the book](https://godot-rust.github.io/book/register/constants.html).

godot/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,15 @@ pub mod register {
177177
pub use godot_core::registry::property;
178178
pub use godot_macros::{godot_api, Export, GodotClass, GodotConvert, Var};
179179

180+
#[cfg(feature = "__codegen-full")]
181+
pub use godot_core::registry::RpcConfig;
182+
180183
/// Re-exports used by proc-macro API.
181184
#[doc(hidden)]
182185
pub mod private {
183186
#[cfg(feature = "__codegen-full")]
184187
pub use godot_core::registry::class::auto_register_rpcs;
188+
185189
pub use godot_core::registry::godot_register_wrappers::*;
186190
pub use godot_core::registry::{constant, method};
187191
}

itest/rust/src/register_tests/rpc_test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
*/
7+
78
use godot::classes::multiplayer_api::RpcMode;
89
use godot::classes::multiplayer_peer::TransferMode;
910
use godot::classes::{Engine, MultiplayerApi};
10-
use godot::meta::RpcConfig;
1111
use godot::prelude::*;
12+
use godot::register::RpcConfig;
1213
use godot::test::itest;
1314

1415
#[derive(GodotClass)]

0 commit comments

Comments
 (0)