4 ms·
I spent some time doing exactly this a couple of months ago, and I agree, Mozilla's UniFFI is really cool. It's also what I'd probably recommend at this time if
by arcticbull 3y ago
I spent some time doing exactly this a couple of months ago, and I agree, Mozilla's UniFFI is really cool. It's also what I'd probably recommend at this time if you're trying do Rust code sharing across higher-level platforms like iOS and Android.
You do have to write an export header spec in 'UDL' (a Mozilla authored interface definition language with a JetBrains plug-in to make it easier to write) - but in exchange, you get proper (idiomatic) Kotlin, Swift, Ruby and Python bindings for your Rust modules. It's nice that for instance the Swift bindings are actually 'native' instead of implemented via Objective-C interop (which would have arguably been simpler).
[edit] I should note that the Kotlin bindings are a little wonky for non-scalar types because they're exported as AutoCloseable resources, and care must be taken to use them correctly. [1]
[1] https://mozilla.github.io/application-services/book/howtos/uniffi-object-destruction-on-kotlin.html https://mozilla.github.io/application-services/book/howtos/u...