Skip to content

Conversation

oguzkocer
Copy link
Contributor

This PR is a major pivot from Rust being the major architecture component to being a helper library. The main reason we are doing this is because of the restrictions we have in FFI layer. Specifically on Android, we found that calling Kotlin from Rust is less than ideal - as JVM can drop the memory or the memory might be in a different thread. Although these issues are possible to get around, we don't want to build a new library on a house of cards.

We've gone through several design explorations so far and this time, we are going to keep the FFI layer as simple as possible by making the Rust library act as a helper. There will never ™️ be a callback from Rust to native and there won't be any asynchronous code - not for now anyway. We still get the benefit of generating the bindings, so we can work with the same objects in Kotlin, Swift and Rust. We are also able to build a generic request in the shared layer and parse a generic response to a specific type. This still leaves some room for extensibility in the future where we can build more "helpers" on top - i.e. for caching.

A lot of this code was written extremely quickly to prove whether this approach works or not. So, it should be treated mostly as a throwaway code and not used in production. We still have a few things we'd like to test on top of this - for example Swift bindings and implementation. So, we'll merge it as is for now. Once - and if - we decide to proceed with the project, it should be relatively straightforward to clean up the code.


Note that the Android layer has some extra changes applied and removed in the commit history of this PR. I've thought about removing extra commits that we won't use. However, I found that I re-used some of the code I've written for previous experiments, so I believe there is benefit in keeping them in the git history.

@oguzkocer oguzkocer merged commit 60be73c into trunk Jan 24, 2024
@oguzkocer oguzkocer deleted the switch-to-rust-being-a-helper-library branch January 24, 2024 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant