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

Expose Extensions during ser+de through ron::Options #343

Merged
merged 4 commits into from
Dec 3, 2021

Conversation

juntyr
Copy link
Member

@juntyr juntyr commented Nov 19, 2021

This PR is based on #281 and #339 (with a potential application for #334 as well).

  1. It adds a new Options struct from which all ser+de utils methods can be called.
  2. The existing utils methods XXX now use Options::default().XXX as their implementation.
  3. The Options struct can be configured with a set of default RON extensions
    a) During deserialization default extensions are automatically enabled, i.e. do not have to be included in the RON.
    b) During serialization default extensions are automatically enabled and are not included in the output RON. Additional extensions enabled through the PrettyConfig which are not in the set of default extensions are still included in the output RON. Therefore, this PR supersedes Add output_extensions option to PrettyConfig #339.
    c) This now enables programs which always use a set of extensions to enable them programmatically and exclude them from the RON config files.
  4. This PR is fully backwards compatible by adding one extra method each to the Serializer and Deserializer and not changing the default behaviour (i.e. no default extensions).
  5. This PR also does a tiny bit of cleanup in the docs and Default impl for PrettyConfig.
  • Add and update the documentation
  • I've included my change in CHANGELOG.md

@juntyr
Copy link
Member Author

juntyr commented Nov 19, 2021

@torkleyy Here's my initial attempt at the Option - I'm looking forward to your feedback!

Copy link
Contributor

@torkleyy torkleyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review. I like where this is going!

src/options.rs Outdated Show resolved Hide resolved
@juntyr
Copy link
Member Author

juntyr commented Dec 1, 2021

Sorry for the late review. I like where this is going!

@torkleyy If you like the API as it is right now (and you give me the go-ahead), I'll start updating the documentation.

Copy link
Contributor

@torkleyy torkleyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, go ahead 👍

@juntyr juntyr marked this pull request as ready for review December 3, 2021 10:07
@juntyr juntyr requested a review from torkleyy December 3, 2021 10:07
@juntyr
Copy link
Member Author

juntyr commented Dec 3, 2021

@torkleyy I've added documentation and the CHANGELOG entry. I also made the following changes to the Options API:

I've also made some minor code cleanup adjustments:

  • moved the Position from parse to errors as it is exposed anyways (both in de and error and rustdoc was not showing them as the exact same struct)
  • made ser::State private
  • hid the doc for ser::Compound as it is an implementation detail but cannot be private
  • simplified PrettyConfig's Default impl so that it isn't duplicated between serde and Default

src/ser/mod.rs Show resolved Hide resolved
src/options.rs Show resolved Hide resolved
@torkleyy torkleyy merged commit 521e639 into ron-rs:master Dec 3, 2021
@juntyr juntyr deleted the ron-options branch December 18, 2021 10:49
torkleyy added a commit to torkleyy/ron that referenced this pull request Jun 6, 2022
Expose `Extensions` during ser+de through `ron::Options`
@torkleyy torkleyy mentioned this pull request Jun 6, 2022
2 tasks
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

Successfully merging this pull request may close these issues.

2 participants