Module uniffi::ffi::foreignfuture
Expand description
This module defines a Rust Future that wraps an async foreign function call.
The general idea is to create a [oneshot::Channel], hand the sender to the foreign side, and await the receiver side on the Rust side.
The foreign side should:
- Input a ForeignFutureCallback and a
u64
handle in their scaffolding function. This is the sender, converted to a raw pointer, and an extern “C” function that sends the result. - Return a ForeignFuture, which represents the foreign task object corresponding to the async function.
- Call the ForeignFutureCallback when the async function completes with:
- The
u64
handle initially passed in - The
ForeignFutureResult
for the call
- The
- Wait for the [ForeignFutureHandle::free] function to be called to free the task object. If this is called before the task completes, then the task will be cancelled.
Structs
- Perform a call to a foreign async method C struct that represents the foreign future.
- C struct that represents the result of a foreign future
Functions
Type Definitions
- Callback that’s passed to a foreign async functions.
- Handle for a callback data associated with a foreign future.
- Handle for a foreign future