Trait SignalReceiver

pub trait SignalReceiver<C, Ps>: 'static {
    // Required method
    fn call(&mut self, maybe_instance: C, params: Ps);
}
Expand description

Trait that is implemented for functions that can be connected to signals.

This is used in ConnectBuilder. There are three variations of the C (class instance) parameter:

  • () for global and associated (“static”) functions.
  • &C for &self methods.
  • &mut C for &mut self methods.

See also Signals in the book.

§Usage as a bound

To write generic code that handles different functions and forwards them to TypedSignal and ConnectBuilder APIs, you have to use SignalReceiver in combination with IndirectSignalReceiver. Consult the docs of the latter for elaboration.

§Hidden impls in this doc

To keep this documentation readable, we only document one variant of each impl SignalReceiver: arbitrarily the one with three parameters (P0, P1, P2). Keep this in mind when looking at a concrete signature.

Required Methods§

fn call(&mut self, maybe_instance: C, params: Ps)

Invoke the receiver on the given instance (possibly ()) with params.

Implementors§

§

impl<F, R, C, P0, P1, P2> SignalReceiver<&mut C, (P0, P1, P2)> for F
where P0: Debug + FromGodot + 'static, P1: Debug + FromGodot + 'static, P2: Debug + FromGodot + 'static, F: FnMut(&mut C, P0, P1, P2) -> R + 'static,

§

impl<F, R, C, P0, P1, P2> SignalReceiver<Gd<C>, (P0, P1, P2)> for F
where P0: Debug + FromGodot + 'static, P1: Debug + FromGodot + 'static, P2: Debug + FromGodot + 'static, F: FnMut(Gd<C>, P0, P1, P2) -> R + 'static, C: GodotClass,

§

impl<F, R, P0, P1, P2> SignalReceiver<(), (P0, P1, P2)> for F
where P0: Debug + FromGodot + 'static, P1: Debug + FromGodot + 'static, P2: Debug + FromGodot + 'static, F: FnMut(P0, P1, P2) -> R + 'static,