First of all, here's a quick example demonstrating what I'm trying to accomplish: Rust Playground
I need to pass a Rust reference to a function declared in a shared library (written in Rust). The library keeps the reference, but does not do anything with it other than passing it back to the calling process at a later time as "context" in static callback.
Compiling the code I get the following:
warning: `extern` block uses type `Box<dyn Trait>`, which is not FFI-safe
I understand that this stems from the fact that my Context
structure contains Rust-types that are not FFI safe (in this case a Box
).
Ideally, I'd want to get rid of this warning, but I'm wondering if this might pose problems if I'm just passing the reference from Rust <--> Rust?
What would be the idiomatic Rust way of doing this?