@@ -693,8 +693,8 @@ pub fn derive_godot_class(input: TokenStream) -> TokenStream {
693
693
/// | Transfer mode | [`TransferMode`] | **`unreliable`**, `unreliable_ordered`, `reliable` |
694
694
/// | Channel | `u32` | any |
695
695
///
696
- /// You can also use `#[rpc(config = value)]`, with `value` being a constant of type [`RpcConfig`] in scope. This can be useful to reuse
697
- /// configurations across multiple RPCs.
696
+ /// You can also use `#[rpc(config = value)]`, with `value` being an expression of type [`RpcConfig`] in scope, for example a `const` or the
697
+ /// call to a function. This can be useful to reuse configurations across multiple RPCs.
698
698
///
699
699
/// `#[rpc]` implies `#[func]`. You can use both attributes together, if you need to configure other `#[func]`-specific keys.
700
700
///
@@ -719,14 +719,26 @@ pub fn derive_godot_class(input: TokenStream) -> TokenStream {
719
719
/// fn explicit(&mut self) {}
720
720
///
721
721
/// #[rpc(config = MY_RPC_CONFIG)]
722
- /// fn external_config(&mut self) {}
722
+ /// fn external_config_const(&mut self) {}
723
+ ///
724
+ /// #[rpc(config = my_rpc_provider())]
725
+ /// fn external_config_fn(&mut self) {}
723
726
/// }
724
727
///
725
728
/// const MY_RPC_CONFIG: RpcConfig = RpcConfig {
729
+ /// rpc_mode: RpcMode::AUTHORITY,
726
730
/// transfer_mode: TransferMode::UNRELIABLE_ORDERED,
731
+ /// call_local: false,
727
732
/// channel: 2,
728
- /// ..Default::default()
729
733
/// };
734
+ ///
735
+ /// fn my_rpc_provider() -> RpcConfig {
736
+ /// RpcConfig {
737
+ /// transfer_mode: TransferMode::UNRELIABLE_ORDERED,
738
+ /// channel: 2,
739
+ /// ..Default::default() // only possible in fn, not in const.
740
+ /// }
741
+ /// }
730
742
/// ```
731
743
///
732
744
// Note: for some reason, the intra-doc links don't work here, despite dev-dependency on godot.
0 commit comments