Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd (de)serialization of internal representation, to avoid re-parsing #259
Conversation
erickt
commented
Dec 19, 2016
|
Looks good to me from the serde angle. |
|
|
@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 |
|
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. |
|
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} | |||
This comment has been minimized.
This comment has been minimized.
SimonSapin
Dec 22, 2016
Author
Member
nox correctly points out that this is a breaking change. @Manishearth why this change? Can we do without it?
This comment has been minimized.
This comment has been minimized.
Manishearth
Dec 22, 2016
Member
Because bincode needs 0.8.20 and cargo isn't smart enough to coalesce the versions in a test-only dependency.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors-servo r=Manishearth |
|
|
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 -->
|
|
SimonSapin commentedDec 19, 2016
•
edited by larsbergstrom
+ random drive-by fixes.
The trick used here to avoid a complex
Deserializeimpl (either hand-written on in a cumbersome generated file) is to use existing impls, namely those ofOptionandIpAddr.@Manishearth, another change from your PR is checking invariants unconditionally (including release mode) so there there is no need for separate
(de)serialize_unsafemethods. Does this run-time cost sound acceptable?r? @Manishearth
This change is