fn rust_future_scaffolding_fns(module_path: &str) -> TokenStream
Expand description

Generates the rust_future_* functions

The foreign side uses a type-erased Handle to interact with futures, which presents a problem when creating scaffolding functions. What is the ReturnType parameter of RustFutureFfi?

Handle this by using some brute-force monomorphization. For each possible ffi type, we generate a set of scaffolding functions. The bindings code is responsible for calling the one corresponds the scaffolding function that created the Handle.

This introduces safety issues, but we do get some type checking. If the bindings code calls the wrong rust_future_complete function, they should get an unexpected return type, which hopefully will result in a compile-time error.