- Is it possible to call async functions from Rust to Rust across a dynamic linking boundary?
- Question like above, but additionally with a requirement that the plugin could be compiled with a different version of rustc.
It's technically possible, but somewhat fiddly.
The easy way would be to use Box<dyn Future>
if you're linking code compiled using the same Rust version on both sides.
But Rust's dyn Trait
objects don't officially have a stable ABI, so if you need something less fragile, you need to do it the hard way, and make your own ABI for futures. Something like a struct with custom function pointers/callbacks for polling the future and drop
for cleanup. You may also need to create a custom ABI wrapper for the Context
and Waker
. Unfortunately, libstd doesn't expose ability to deconstruct Waker
into RawWakerVTable
fields, so you'll need to make your own waker wrapper.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.