pub trait StaticArgsAsyncMethod<C: NativeClass>: Send + Sync + 'static {
type Args: FromVarargs;
fn spawn_with(&self, spawner: Spawner<'_, C, Self::Args>);
fn site() -> Option<Site<'static>> { ... }
}
Expand description
Trait for async methods whose argument lists are known at compile time. Not to
be confused with a “static method”. 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 Associated Types§
type Args: FromVarargs
Required Methods§
sourcefn spawn_with(&self, spawner: Spawner<'_, C, Self::Args>)
fn spawn_with(&self, spawner: Spawner<'_, C, Self::Args>)
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.