This is one of the approaches for FFI taken by other runtimes, however it has the issue that without binding generators (jextract, P/Invoke code generators, ctypesgen), the type declarations are a pain to write.
Thus something like this would need a similar tool.
deno_bindgen exists which can be used to do this from Rust.
I have written a partial solution for C, though it is bespoke for my libclang bindings, and a very rough one for C++. Both of these require more work to really be ready-to-use tools however.
Thus something like this would need a similar tool.