toml icon indicating copy to clipboard operation
toml copied to clipboard

Release `easy::Value` as a separate (1.0?) crate

Open sunshowers opened this issue 3 years ago • 5 comments

I'd love to expose toml_edit::easy::Value (identical to toml-rs's Value?) in some public APIs in guppy. I'm thinking it could maybe be released as a separate crate (say toml-value), to allow toml_edit to continue to iterate on its API without breaking compat.

Some thoughts:

  • this could be a stable API, I don't think it's changed in toml-rs in a while.
  • it also means that the easy module can go away, or just re-export toml-value.

sunshowers avatar Nov 24 '21 02:11 sunshowers

Sorry for the delayed response.

This would definitely help towards a 1.0. I'm assuming this would be a complete drop-in replacement for toml-rs. This means we'd need errors and deserializers. We'd probably create newtypes of the ones in toml_edit.

The one area of concern is for people using both crates. like cargo. You could have two different toml_edits in your dependency tree with different behaviors. With rigor, you could avoid the parts of toml-value that touch toml_edit.

Options for improving this

  • toml-value has a feature flag for serialization, that is enabled by default. cargo could disable default features. The big question is if we can do this and keep it close enough to toml-rs for cargo's needs
  • toml-value is only the data model and toml_edit re-exports it. Again, we'd need to check what, if anything, we lose from this.

epage avatar Nov 25 '21 17:11 epage

yeah, I'm thinking that toml-value is just the data model, with an optional serde feature for Serialize and Deserialize support (so not a complete replacement for toml-rs, which also has a parser and serializer). I'd expect toml_edit to stay as it is.

sunshowers avatar Nov 25 '21 18:11 sunshowers

@ordian what are your thoughts on splitting out a toml-value for other crates to use in their public API? toml_edit::easy would then just re-export this.

I've been using cargo-release for the releases which handles workspaces, so it shouldn't be an issue from the release process perspective.

epage avatar Nov 25 '21 18:11 epage

It makes sense to me. Go for it :)

ordian avatar Nov 25 '21 18:11 ordian

Originally, I hesitated on this from laziness (all of the serializable logic needed for try_from and try_into but I forgot about the Dsplay needing a toml formatter. That makes splitting out only the data model a lot more complicated while maintaining the toml-rs API.

epage avatar Jan 13 '22 15:01 epage

With #340, toml_edit::easy::Value will be moving to toml::Value. Closing this in favor of that issue

epage avatar Jan 13 '23 17:01 epage