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

Implement serde Serialize/Deserialize for VersionReq #119

Closed
brson opened this issue Jul 13, 2017 · 8 comments
Closed

Implement serde Serialize/Deserialize for VersionReq #119

brson opened this issue Jul 13, 2017 · 8 comments

Comments

@brson
Copy link
Contributor

brson commented Jul 13, 2017

Only when the "serde" feature is enabled. It's implemented for Version but not VersionReq. I imagine this wants a custom serializer, not a derived one. Maybe @steveklabnik you can say more about how this should be implemented and tag it help wanted.

@steveklabnik
Copy link
Contributor

I'm not sure what the use-case is, so I'm not sure why it'd want to be custom.

@brson
Copy link
Contributor Author

brson commented Jul 14, 2017

This is a type with a natural string form, so I thought it might want to be serialized in that form - for comparison, Version uses a custom serializer.

A contributor can probably start out with derived serialization and hash it out on the PR.

@brson
Copy link
Contributor Author

brson commented Jul 14, 2017

Oh, actually, my use case was to deserialize version requirements from the crates.io API into a VersionReq. I presume that would require a custom serializer / deserializer, but don't know for sure. In the crates.io API they are just strings that are shaped like version requirements.

@steveklabnik
Copy link
Contributor

Yeah I mean, one problem with VersionReq generally is that there's no "normal form" for them; that is, you could construct two different VersionReqs with different constraints that result in the same set of versions, so they wouldn't be equal to each other anymore... I'm wondering if that's an issue with serialization.

Maybe trying out the default one and seeing if it works for crates.io is the right call.

bjgill added a commit to bjgill/cargo_metadata that referenced this issue Aug 23, 2017
`kind` has the specialised `DependencyKind`; `req` is just a string -
see dtolnay/semver#119
bjgill added a commit to bjgill/cargo_metadata that referenced this issue Aug 26, 2017
`kind` has the specialised `DependencyKind`; `req` is just a string -
see dtolnay/semver#119
@KodrAus
Copy link

KodrAus commented Sep 18, 2017

Is this all sorted now?

@opilar
Copy link
Contributor

opilar commented Sep 24, 2017

Seems it's already in release 0.8.0. Should be ok.

@valarauca
Copy link

valarauca commented Jan 13, 2020

As of 0.9.0 this does not appear to work

Edit:

semver = { version = "0.9.0", features = ["serde"] }

that works. Had to read the Cargo.toml to figure it out.

@dtolnay
Copy link
Owner

dtolnay commented May 25, 2021

This was implemented in #122.

@dtolnay dtolnay closed this as completed May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants