Skip to main content

launch_async

Function launch_async 

Source
pub fn launch_async<T, S, Fut>(
    prepare: impl FnOnce() -> Result<(Fut, Option<CancelToken>), FfiError>,
    lower: impl FnOnce(T) -> S + Send + 'static,
    deliver: impl FnOnce(*mut FfiError, S) + Send + 'static,
)
where T: 'static, S: Sentinel, Fut: Future<Output = Result<T, FfiError>> + Send + 'static,
Expand description

The body of every generated async launcher.

prepare runs on the caller’s thread under catch_unwind: it lifts the launcher’s inputs into owned values and returns the producer’s future (with the call’s cancel token, for a cancellable function), or the first input that failed to lift. lower turns the producer’s value into the completion callback’s result slots, and deliver invokes the callback with a heap-boxed error (or null) and those slots; on any failure the slots are Sentinel::sentinel values. deliver runs exactly once, from any thread, possibly before this returns.