Implement Serialize and Deserialize for Static

This commit is contained in:
Curtis McEnroe 2016-01-25 20:52:55 -05:00
parent cb3f9745b1
commit 99c7481698
2 changed files with 16 additions and 0 deletions

View File

@ -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};

View File

@ -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<S: Serializer>(&self, serializer: &mut S) -> Result<(), S::Error> {
serializer.visit_unit_struct("Static")
}
}
impl Deserialize for Static {
fn deserialize<D: Deserializer>(deserializer: &mut D) -> Result<Self, D::Error> {
deserializer.visit_unit_struct("Static", UnitVisitor)
.and(Ok(Static))
}
}
#[cfg(test)]
mod tests {
use rustc_serialize::json::Json;