diff --git a/src/lib.rs b/src/lib.rs index ffad986..3a2d01c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -139,6 +139,7 @@ extern crate chrono; extern crate hyper; extern crate rustc_serialize; +extern crate serde; extern crate url; pub use token::{Token, Lifetime}; diff --git a/src/token/statik.rs b/src/token/statik.rs index 3180588..620ecdb 100644 --- a/src/token/statik.rs +++ b/src/token/statik.rs @@ -1,4 +1,6 @@ use rustc_serialize::json::Json; +use serde::{Serialize, Serializer, Deserialize, Deserializer}; +use serde::de::impls::UnitVisitor; use super::Lifetime; use client::response::{FromResponse, ParseError, JsonHelper}; @@ -21,6 +23,19 @@ impl FromResponse for Static { } } +impl Serialize for Static { + fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> { + serializer.visit_unit_struct("Static") + } +} + +impl Deserialize for Static { + fn deserialize(deserializer: &mut D) -> Result { + deserializer.visit_unit_struct("Static", UnitVisitor) + .and(Ok(Static)) + } +} + #[cfg(test)] mod tests { use rustc_serialize::json::Json;