Skip to main content

run_async

Function run_async 

Source
pub fn run_async<T, Fut, C>(fut: Fut, cancel: Option<CancelToken>, complete: C)
where T: 'static, Fut: Future<Output = Result<T, FfiError>> + Send + 'static, C: FnOnce(Result<T, FfiError>) + Send + 'static,
Expand description

Run an async export to completion and deliver its result exactly once.

fut is the producer’s work, already mapped to Result<T, FfiError> (a domain error becomes its FfiError); complete lowers the outcome into the C completion callback’s slots and invokes it. The runtime calls complete exactly once:

  • with fut’s result when it resolves;
  • with a PANIC_ERROR_CODE error when polling it panics;
  • with CANCELLED_ERROR_CODE as soon as cancel fires, after dropping fut, or when the executor drops the task before it resolves;
  • with GENERIC_ERROR_CODE when the executor can’t take the task (see spawn).