Skip to content

Commit 2ae2995

Browse files
committed
Follow-up changes to RpcConfig + #[cfg] + clippy
1 parent c4dd6b7 commit 2ae2995

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

godot-core/src/meta/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ mod godot_convert;
4040
mod method_info;
4141
mod property_info;
4242
mod ref_arg;
43-
// RpcConfig uses `MultiplayerPeer::TransferMode` and `MultiplayerApi::RpcMode`,
44-
// which are only available when `codegen-full` is enabled.
43+
// RpcConfig uses MultiplayerPeer::TransferMode and MultiplayerApi::RpcMode, which are only enabled in `codegen-full` feature.
4544
#[cfg(feature = "codegen-full")]
4645
mod rpc_config;
4746
mod sealed;

godot-core/src/meta/rpc_config.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ use crate::classes::Node;
1212
use crate::dict;
1313
use crate::meta::ToGodot;
1414

15-
/// See [Godot documentation](https://docs.godotengine.org/en/stable/tutorials/networking/high_level_multiplayer.html#remote-procedure-calls)
15+
/// Configuration for a remote procedure call, typically used with `#[rpc(config = ...)]`.
16+
///
17+
/// See [Godot documentation](https://docs.godotengine.org/en/stable/tutorials/networking/high_level_multiplayer.html#remote-procedure-calls).
1618
#[derive(Copy, Clone, Debug)]
1719
pub struct RpcConfig {
1820
pub rpc_mode: RpcMode,
@@ -34,12 +36,12 @@ impl Default for RpcConfig {
3436

3537
impl RpcConfig {
3638
/// Register `method` as a remote procedure call on `node`.
37-
pub fn register(self, node: &mut Node, method: impl Into<StringName>) {
38-
node.rpc_config(method.into(), &self.into_dictionary().to_variant());
39+
pub fn configure_node(self, node: &mut Node, method_name: impl Into<StringName>) {
40+
node.rpc_config(method_name.into(), &self.to_dictionary().to_variant());
3941
}
4042

41-
/// Returns a [`Dictionary`] populated with the values required for a call to [`Node::rpc_config`].
42-
pub fn into_dictionary(self) -> Dictionary {
43+
/// Returns a [`Dictionary`] populated with the values required for a call to [`Node::rpc_config()`].
44+
pub fn to_dictionary(&self) -> Dictionary {
4345
dict! {
4446
"rpc_mode": self.rpc_mode,
4547
"transfer_mode": self.transfer_mode,

godot-core/src/private.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub use crate::meta::trace;
1919

2020
use crate::global::godot_error;
2121
use crate::meta::error::CallError;
22-
use crate::meta::{CallContext, ClassName};
22+
use crate::meta::CallContext;
2323
use crate::sys;
2424
use std::sync::{atomic, Arc, Mutex};
2525
use sys::Global;
@@ -129,7 +129,8 @@ pub(crate) fn iterate_plugins(mut visitor: impl FnMut(&ClassPlugin)) {
129129
sys::plugin_foreach!(__GODOT_PLUGIN_REGISTRY; visitor);
130130
}
131131

132-
pub(crate) fn find_inherent_impl(class_name: ClassName) -> Option<InherentImpl> {
132+
#[cfg(feature = "codegen-full")] // Remove if used in other scenarios.
133+
pub(crate) fn find_inherent_impl(class_name: crate::meta::ClassName) -> Option<InherentImpl> {
133134
// We do this manually instead of using `iterate_plugins()` because we want to break as soon as we find a match.
134135
let plugins = __godot_rust_plugin___GODOT_PLUGIN_REGISTRY.lock().unwrap();
135136

godot-core/src/registry/class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl ClassRegistrationInfo {
7171
// Note: when changing this match, make sure the array has sufficient size.
7272
let index = match item {
7373
PluginItem::Struct { .. } => 0,
74-
PluginItem::InherentImpl(InherentImpl { .. }) => 1,
74+
PluginItem::InherentImpl(_) => 1,
7575
PluginItem::ITraitImpl { .. } => 2,
7676
};
7777

godot-macros/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ homepage = "https://godot-rust.github.io"
1313
[features]
1414
api-custom = ["godot-bindings/api-custom"]
1515
docs = ["dep:markdown"]
16-
codegen-full = []
16+
codegen-full = ["godot/__codegen-full"]
1717

1818
[lib]
1919
proc-macro = true
@@ -32,7 +32,7 @@ godot-bindings = { path = "../godot-bindings", version = "=0.1.3" } # emit_godot
3232

3333
# Reverse dev dependencies so doctests can use `godot::` prefix.
3434
[dev-dependencies]
35-
godot = { path = "../godot", default-features = false, features = ["__codegen-full"] }
35+
godot = { path = "../godot", default-features = false}
3636

3737
# https://docs.rs/about/metadata
3838
[package.metadata.docs.rs]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn make_rpc_registration(func_def: &FuncDefinition) -> Option<TokenStream> {
154154
let registration = quote! {
155155
{
156156
#create_struct
157-
args.register(node, #method_name_str)
157+
args.configure_node(node, #method_name_str)
158158
}
159159
};
160160

0 commit comments

Comments
 (0)