async rust calls swift?
Hi, I couldn't see this in the guide, so assuming it's a no, but worth asking!
I have a use case where I'd like to call Swift and Kotlin from a rust application. Is this possible, especially with async, using uniffi? I can see how you might implement a set of exposed functions in a static swift library which trigger callbacks to pass data to rust, but is it possible in this crate to have full async/await functionality going in this direction?
Many thanks!
Is this what you're looking for? https://mozilla.github.io/uniffi-rs/0.29/futures.html
don't believe so, this is for calling async rust fn from another language, i want the other way around - calling async swift fn from rust. I'm making a pure rust project, i just need to tap into a couple of native api's in swift. I've done smth similar with swift-bridge but it uses callback fnonce closures, not true async/await.
What happens if you define a method that accepts async fn in rust. Does it translate to async fn in Swift bindings?
Callback interfaces can have async methods - https://mozilla.github.io/uniffi-rs/latest/futures.html#exporting-async-trait-methods - which I think is roughly what you are asking for?
Agree i think this is possible, there is a little added complexity from the fact that uniffi is set up to be driven from the non-rust languages with callbacks or trait objects being passed to rust to allow rust to talk back the other way. In the case of a rust app initiating this process, there isn't any built in way to kick things off from rust. It should be possible with some home-rolled ffi to trigger e.g. rust calls swift exposed fn, swift passes back the trait object rust needs to call swift fn's on, then proceed as per the examples.