uniffi-rs
uniffi-rs copied to clipboard
Serialize a UniFFI object to JSON from the foreign platform code
Consumers of my Rust code, in Kotlin and Swift, want to serialize several of our #[uniffi::Record] objects to a JSON string (in order to pass it through yet another layer of FFI). Is this possible currently?
In the docs it looks like UniFFI supports exposing functions from standard Rust crates, however serde::Serialize is not listed here.
I've tried creating a generic helper function to serialize any serializable object. However it looks like #[uniffi::export] doesn't support functions with generic arguments. I could create a separate exported function for each JSON-serializable type, but this would be inconvenient.
For Swift specifically, ideally the generated type implements Encodable.