Implement Serialize and Deserialize for Static
This commit is contained in:
parent
cb3f9745b1
commit
99c7481698
|
@ -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};
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue