feat(rust): import stubs for native targets#1565
Conversation
|
Thanks for the PR, and I'm trying to page this all back in and understand the motivations/intentions here. Correct me if I'm wrong, but the high level idea is to be able to satisfy, on non-wasm platforms, wit-bindgen-generated bindings with a native implementation. Is that correct? If so, I'm second-guessing this a bit in the sense of why go through ABI-marshalling at all? For example if you're calling a WIT function it seems like it'd be best to just turn around and immediately call a native function rather than serializing to some ABI-based representation just to deserialize and call a host function. Does that make sense to fit in here at all? Or am I perhaps missing something? (I could very well be) |
|
This PR despite making the possible stubs very modular, suffers from a lot of issues, I'm going to close this in favor of another PR that I've been making. The idea is a bit different, and slightly more complex then just calling a host function, since that would require the host binary to be compiled with "-rdynamic" on linux, and it wouldn't even work on Windows and MacOS. |
This PR adds the ability for the user to provide a macro to rust that then can generate native funciton stubs, as described in #1062.
There were a few explored different alternatives, and the reasoning for using a macro is provided in the original issue.
There are still a few things I'd like to change, but as a proof of concept you can do something like the following to automatically create a trait for all native stubs.
I have a minimum testing repo that can be found here