Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value meta-issue #397

Open
11 of 17 tasks
juntyr opened this issue Aug 15, 2022 · 1 comment
Open
11 of 17 tasks

Value meta-issue #397

juntyr opened this issue Aug 15, 2022 · 1 comment
Assignees

Comments

@juntyr juntyr self-assigned this Aug 15, 2022
@juntyr
Copy link
Member Author

juntyr commented Aug 17, 2022

I've been thinking about the ron Value for a few days and wanted to summarise my thoughts:

  • the Value type should be extended to be more like a ron AST (extensions excluded?)
  • most issues stem from ron having a type system (in the data format) that is both more and less expressive than serde's de::Visitor API. On the one hand, ron has named units, (named) tuples, (named) struct-likes, all in addition to serde's sequences and maps. On the other hand, it does not distinguish between structs and enums.
  • serialising into a Value should be no problem, but it might be useful to not make Value a Serializer itself but instead reuse the existing Serializer to benefit from the extension handling (i.e. serialising into a Value should give the ron as serialising to a String)
  • deserialising from an extended Value should present little problems, but would also benefit from plugging into the existing Deserializer to handle the unwrap extensions. That way, all non-self-describing methods should work flawlessly
  • deserialize_any could be adapted to support serde's untagged functionality ... to some extent (the unwrap extensions will never work with it since it requires support from our Deserializer) ... perhaps this should be a separate issue
  • transforming a Value into a ron string is trivial, but could perhaps be integrated with the Serializer to support the same PrettyConfig
  • implementing Deserialize for Value is the difficult part, since serde just doesn't give us sufficient information for it to work losslessly. Perhaps we should, therefore, split the functionality into (1) a Value can be serialised and deserialised by any data format - but this does not mean you can deserialise a Value from a ron string, and (2) a Value can be parsed from a ron string. This change would be breaking since Value's Serialize and Deserialize impls would do something very different from before, while the functionality of going between ron and Value would be exposed in separate methods.

@torkleyy what are your thoughts on this?

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

No branches or pull requests

1 participant