-
Notifications
You must be signed in to change notification settings - Fork 335
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
Add (de)serialization of internal representation, to avoid re-parsing #259
Conversation
Looks good to me from the serde angle. |
☔ The latest upstream changes (presumably #260) made this pull request unmergeable. Please resolve the merge conflicts. |
@nox disagrees. I am okay with this situation, sort of. |
r+ otherwise. Good idea. |
I asked for separate methods because otherwise rust-url becomes pretty much useless to deserialize from JSON or TOML in the wild, where no one cares about the internal representation in rust-url. |
IMO |
cc63d5e
to
bb0fdb5
Compare
What do you mean? Many people use serde to serialise configuration and whatnot. Our serde support ought to serialise as values which make sense in most contexts of serde. The internal representation isn't one of them. What about formats which don't even have a serialiser? Also, this is a breaking change. |
bb0fdb5
to
94e8d76
Compare
Alright, I’ve changed the PR to leave the existing impls alone and add new inherent methods instead. r? @nox |
@@ -38,4 +39,4 @@ heapsize = {version = ">=0.1.1, <0.4", optional = true} | |||
idna = { version = "0.1.0", path = "./idna" } | |||
matches = "0.1" | |||
rustc-serialize = {version = "0.3", optional = true} | |||
serde = {version = ">=0.6.1, <0.9", optional = true} | |||
serde = {version = "0.8.20", optional = true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nox correctly points out that this is a breaking change. @Manishearth why this change? Can we do without it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because bincode needs 0.8.20 and cargo isn't smart enough to coalesce the versions in a test-only dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use JSON instead for the test and revert this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go ahead
94e8d76
to
5f5b943
Compare
@bors-servo r=Manishearth |
📌 Commit 5f5b943 has been approved by |
Add (de)serialization of internal representation, to avoid re-parsing + random drive-by fixes. The trick used here to avoid a complex `Deserialize` impl (either hand-written on in a cumbersome generated file) is to use existing impls, namely those of `Option` and `IpAddr`. @Manishearth, another change from your PR is checking invariants unconditionally (including release mode) so there there is no need for separate `(de)serialize_unsafe` methods. Does this run-time cost sound acceptable? r? @Manishearth <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/259) <!-- Reviewable:end -->
☀️ Test successful - status-travis |
+ random drive-by fixes.
The trick used here to avoid a complex
Deserialize
impl (either hand-written on in a cumbersome generated file) is to use existing impls, namely those ofOption
andIpAddr
.@Manishearth, another change from your PR is checking invariants unconditionally (including release mode) so there there is no need for separate
(de)serialize_unsafe
methods. Does this run-time cost sound acceptable?r? @Manishearth
This change is