I have:
- A Rust library that is compiled to a static C library
- A Go program that calls the Rust library's API via CGo
I wish to pass a Go function (as callback) to the Rust code, so it will be able to send logs back to my Go program during runtime, when its library API is executed. Something like sending the cb address and save it inside my already compiled Rust code.
I've examined some examples where Go passes a cb to C using CGo, and C invokes it and it does work. But I couldn't wrap my head around how to transmit that to the Rust code, as if I was 'stopped' at the C interface-side of things.
The only thing I could think about is to declare a mutable empty Global variable inside Rust's library and assign the Go cb to it by passing the cb as a parameter from Go side.
Would that make sense? Any other suggestions?