Trait RustCallable
pub trait RustCallable:
'static
+ PartialEq
+ Hash
+ Display
+ Send
+ Sync {
// Required method
fn invoke(&mut self, args: &[&Variant]) -> Variant;
// Provided methods
fn callable_name(&self) -> Cow<'static, str> { ... }
fn is_valid(&self) -> bool { ... }
}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, Hash is required for usage as a key in a Dictionary and for checking signal connections –
Godot considers a custom callable to be connected to a signal if a callable with the same hash is already connected to that signal.
Finally, PartialEq is necessary for equality checks.
Required Methods§
Provided Methods§
fn callable_name(&self) -> Cow<'static, str>
fn callable_name(&self) -> Cow<'static, str>
Returns the name of this callable for error messages and display.
By default, the Display impl is used. You can override this for a cached/constant name.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.