aboutsummaryrefslogtreecommitdiffstats
path: root/components/url/lib.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-02-10 02:35:26 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2017-02-18 21:09:46 +0100
commitfe3f4ff0c2c7f06be0b4fb4214d1cb86b1e796d8 (patch)
tree7f8a1627a61298f745978a65e966d3674bffae6d /components/url/lib.rs
parent26d6c96b18c02c02522d706e9ce5e24ee381a45e (diff)
downloadservo-fe3f4ff0c2c7f06be0b4fb4214d1cb86b1e796d8.tar.gz
servo-fe3f4ff0c2c7f06be0b4fb4214d1cb86b1e796d8.zip
Update serde to 0.9 (fixes #15325)
Diffstat (limited to 'components/url/lib.rs')
-rw-r--r--components/url/lib.rs25
1 files changed, 21 insertions, 4 deletions
diff --git a/components/url/lib.rs b/components/url/lib.rs
index d9f69497aba..85933a509c7 100644
--- a/components/url/lib.rs
+++ b/components/url/lib.rs
@@ -7,11 +7,10 @@
#![crate_name = "servo_url"]
#![crate_type = "rlib"]
-#![cfg_attr(feature = "servo", feature(plugin))]
-
-#[cfg(feature = "servo")] #[macro_use] extern crate serde_derive;
#[cfg(feature = "servo")] extern crate heapsize;
#[cfg(feature = "servo")] #[macro_use] extern crate heapsize_derive;
+#[cfg(feature = "servo")] extern crate serde;
+#[cfg(feature = "servo")] extern crate url_serde;
extern crate url;
@@ -23,7 +22,7 @@ use std::sync::Arc;
use url::{Url, Origin, Position};
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[cfg_attr(feature = "servo", derive(HeapSizeOf, Serialize, Deserialize))]
+#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct ServoUrl(Arc<Url>);
impl ServoUrl {
@@ -196,3 +195,21 @@ impl From<Url> for ServoUrl {
ServoUrl::from_url(url)
}
}
+
+#[cfg(feature = "servo")]
+impl serde::Serialize for ServoUrl {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where S: serde::Serializer,
+ {
+ url_serde::serialize(&*self.0, serializer)
+ }
+}
+
+#[cfg(feature = "servo")]
+impl serde::Deserialize for ServoUrl {
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+ where D: serde::Deserializer,
+ {
+ url_serde::deserialize(deserializer).map(Self::from_url)
+ }
+}