Trait godot::prelude::RustCallable

pub trait RustCallable: 'static + PartialEq + Hash + Display + Send + Sync {
    // Required method
    fn invoke(&mut self, args: &[&Variant]) -> Result<Variant, ()>;
}
Expand description

Represents a custom callable object defined in Rust.

This trait has a single method, invoke, which is called upon invocation.

Since callables can be invoked from anywhere, they must be self-contained ('static) and thread-safe (Send + Sync). They also should implement Display for the Godot string representation. Furthermore, PartialEq and Hash are required for equality checks and usage as a key in a Dictionary.

Required Methods§

fn invoke(&mut self, args: &[&Variant]) -> Result<Variant, ()>

Invokes the callable with the given arguments as Variant references.

Return Ok(...) if the call succeeded, and Err(()) otherwise. Error handling is mostly needed in case argument number or types mismatch.

Object Safety§

This trait is not object safe.

Implementors§