Closed JohnTheCoolingFan closed 9 months ago
Thank you for reaching out! RON is based on serde and thus supports different representations for enums:
Enum::Variant { a: 42 }
, you write Variant(a: 42)
in RON{ “tag”: “Variant”, “a”: 42 }
(tag: Variant, content: (a: 42))
(a: 42)
You can learn more about how to annotate your Rust data types to use these representations here: https://serde.rs/enum-representations.html
I hope this has somewhat helped you - please feel free to ask again if anything is still unclear :)
Ah, so the default behavior with externally tagged enums is exactly what I'm asking about? Sweet!
I have an idea to use struct names as tags of enums when deserializing and serializing. I've noticed there is enum grammar in the docs: docs/grammar.md but I failed to understand how it can be used.
I've found #519, which probably has the same blockers as this feature would have. I don't know how possible this is to implement and whether it has a lot of usability for others. I plan to use this to load a list of objects from a file and using enum variants would probably be the best way to detect which concrete type to deserialize into.