uniffi-rs
uniffi-rs copied to clipboard
Enum custom type example
Right now all our custom type examples are structs. It could be good to add some Enum examples -- e.g. a JSONObject as a JSONEnum which translates to a serde_json::Value.
There are two issues with serde_json::Value though:
- It's a recursive enum, so we would need to implement #396.
- On Kotlin, I don't think there's a builtin Json type, and we don't want the examples to depend on 3rd party libraries
So we should either resolve those issues, or think of a different Enum example.
┆Issue is synchronized with this Jira Task ┆friendlyId: UNIFFI-125
I vaguely think JSON isn't a great example here, as I don't think a custom enum would make sense in practice - ie, it might mislead people into thinking that exposing JSON via a custom enum is the "correct" approach to a custom JSON type.
Maybe an Any enum?
[Enum]
interface Any {
I32(i32),
String(string),
It doesn't have to be thorough, just enough to demonstrate the idea?
(hrm - I didn't think that through really - the point is not to define the enum in the udl, right? But maybe there's a skerrick of an idea there?)