pub trait AsyncMethod<C: NativeClass>:
Send
+ Sync
+ 'static {
// Required method
fn spawn_with(&self, spawner: Spawner<'_, C>);
// Provided method
fn site() -> Option<Site<'static>> { ... }
}
Expand description
Trait for async methods. When exported, such methods return FunctionState
-like
objects that can be manually resumed or yielded to completion.
Async methods are always spawned locally on the thread where they were created,
and never sent to another thread. This is so that we can ensure the safety of
emitting signals from the FunctionState
-like object. If you need to off-load
some task to another thread, consider using something like
futures::future::Remote
to spawn it remotely on a thread pool.
Required Methods§
Sourcefn spawn_with(&self, spawner: Spawner<'_, C>)
fn spawn_with(&self, spawner: Spawner<'_, C>)
Spawns the future for result of this method with spawner
. This is done so
that implementors of this trait do not have to name their future types.
If the spawner
object is not used, the Godot side of the call will fail, output an
error, and return a Nil
variant.
Provided Methods§
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.