+However despite betting on the wrong horse in this instance, or perhaps more accurately betting on a horse not yet ready to compete - if Android adds support for the foreign memory APIs in the future I could see the trade-offs swinging in favour of Jextract again, migrating to UniFFI instead was surprisingly easy. I had deliberately isolated the FFI code in both Rust and Kotlin so that its only role was to call into the other Rust and Kotlin code respectively. The Rust side had its own module responsible for FFI glue that didn't contain any engine logic itself, and the Kotlin code has its own package implementing generic interfaces for the UI code to use which had almost no knowledge of the FFI implementation at all. Someone forking the app wouldn't have that hard a time replacing the engine with a Kotlin one, at least not until I make the Rust implementation more complex or rely heavily on math libraries. It was relatively simple to write new UniFFI bindings side by side with the existing C header ones for Jextract in the Rust code. Migrating the Kotlin code over was also straightforward - write new implementation of unchanged interface in same file, delete old implementation and rename new one to match, run. For a brief moment in-between commits the interface got to have 2 implementations.
0 commit comments