I would like to use the Rust's FFI to "talk" to Node.js's embedder api.
Currently, Rust's FFI only support foreign C functions and I understand that Node.js's embedder api is targeted to C++.
Is there a way facilitate this from Node.js? Or am I bound to wait until Rust supports C++ FFI?
You could write a small compat api:
extern "C" int init_node(int argc, char** argv) {
std::vector<std::string> args(argv, argv + argc);
std::vector<std::string> exec_args;
std::vector<std::string> errors;
return node::InitializeNodeWithArgs(&args, &exec_args, &errors);
}
extern "C" void* create_platform(...) {
...
}
...
Thank you @devsnek for your reply.
I used your method and was able to expose some functions to Rust.
I will love to see the entire Node.js API exposed as C out of the box. And would also be nice to have libnode.so distributed with each Node.js release.
Most helpful comment
You could write a small compat api: