I'm translating a C app to Rust. The C app dynamically loads dlls, calls into them periodically, and they callback to the app. The dlls were compiled against a C include file with the necessary callback API marked as exported.
How do I do the same in Rust, where both the app and dlls are in Rust? I gather that the dll has to have a dependency on a crate that provides the API - but how can the app and the dll both depend on the same crate in different ways? The dlls should only have access to the "client" side of that API, while the app should have access to the "server" side. Or is there a way to avoid having an extra crate for the API?
The only way I can think of to do this is to not have the dlls depend on a crate for the API. Instead, have the app pass the API into the dlls as closures based on std only. But then I have to marshal info across an interface that only has std types in it, which is going to be very cumbersome.