Skip to main content

WithUserRpcs

Trait WithUserRpcs 

pub trait WithUserRpcs<'c, C>
where C: GodotClass,
{ type Collection: RpcCollection<'c, C>; // Required method fn rpcs(&'c mut self) -> Self::Collection; }
Expand description

Represents an object, generally a node, that can provide a collection of RPCs available on this object.

Implemented by default for classes that inherit Node and contain at least one #[rpc].

Required Associated Types§

Required Methods§

fn rpcs(&'c mut self) -> Self::Collection

Returns Self::Collection, which generally holds a reference to Self. Refer to the chapter about RPCs in the book for more information.

§Provided API

The returned collection provides an API for calling all defined RPCs.

For example, the following RPC:

#[rpc]
fn say_hello_to(&mut self, to: String) {
    godot_print!("hello, {to}");
}

can be called with:

my_node.rpcs().say_hello_to("world".to_string()).call();
my_node.rpcs().say_hello_to("world".to_string()).call_id(1); // call RPC on specific peer

Implementors§

§

impl<'c, C> WithUserRpcs<'c, C> for Gd<C>
where C: Inherits<Node> + WithUserRpcs<'c, C>,

§

type Collection = <C as WithUserRpcs<'c, C>>::Collection