You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
The text was updated successfully, but these errors were encountered:
As you noted, functions with generic args don't work. While records can't have methods, you could have a namespace function which does the serialize - eg fn serialize_my_record(record: &MyRecord) -> String
Re Encodable, #1905 sketches out a proposal which seems workable, but I don't think anyone has started working on that at this stage.
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
.The text was updated successfully, but these errors were encountered: