diff --git a/Cargo.toml b/Cargo.toml index 19b4d3cbf9..03cac5bd1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,13 +32,8 @@ default-features = false version = "0.4" default-features = false -[dependencies.serde] -version = "0.7" -optional = true - [dev-dependencies] env_logger = "0.3" [features] -serde-serialization = ["serde", "mime/serde"] nightly = [] diff --git a/src/header/common/content_length.rs b/src/header/common/content_length.rs index 8c9707aeaa..f5effe4f7a 100644 --- a/src/header/common/content_length.rs +++ b/src/header/common/content_length.rs @@ -72,7 +72,6 @@ impl fmt::Display for ContentLength { } __hyper__deref!(ContentLength => u64); -__hyper_generate_header_serialization!(ContentLength); __hyper__tm!(ContentLength, tests { // Testcase from RFC diff --git a/src/header/common/mod.rs b/src/header/common/mod.rs index 6ec2efafb7..dd20a416ae 100644 --- a/src/header/common/mod.rs +++ b/src/header/common/mod.rs @@ -178,32 +178,6 @@ macro_rules! test_header { } } -#[doc(hidden)] -#[macro_export] -macro_rules! __hyper_generate_header_serialization { - ($id:ident) => { - #[cfg(feature = "serde-serialization")] - impl ::serde::Serialize for $id { - fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> - where S: ::serde::Serializer { - format!("{}", self).serialize(serializer) - } - } - - #[cfg(feature = "serde-serialization")] - impl ::serde::Deserialize for $id { - fn deserialize(deserializer: &mut D) -> Result<$id, D::Error> - where D: ::serde::Deserializer { - let string_representation: String = - try!(::serde::Deserialize::deserialize(deserializer)); - Ok($crate::header::Header::parse_header(&[ - string_representation.into_bytes() - ]).unwrap()) - } - } - } -} - #[macro_export] macro_rules! header { // $a:meta: Attributes associated with the header item (usually docs) @@ -236,8 +210,6 @@ macro_rules! header { self.fmt_header(f) } } - - __hyper_generate_header_serialization!($id); }; // List header, one or more items ($(#[$a:meta])*($id:ident, $n:expr) => ($item:ty)+) => { @@ -264,7 +236,6 @@ macro_rules! header { self.fmt_header(f) } } - __hyper_generate_header_serialization!($id); }; // Single value header ($(#[$a:meta])*($id:ident, $n:expr) => [$value:ty]) => { @@ -290,7 +261,6 @@ macro_rules! header { ::std::fmt::Display::fmt(&**self, f) } } - __hyper_generate_header_serialization!($id); }; // List header, one or more items with "*" option ($(#[$a:meta])*($id:ident, $n:expr) => {Any / ($item:ty)+}) => { @@ -331,7 +301,6 @@ macro_rules! header { self.fmt_header(f) } } - __hyper_generate_header_serialization!($id); }; // optional test module diff --git a/src/header/mod.rs b/src/header/mod.rs index 0c34943f65..89d7fc0eac 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -92,13 +92,6 @@ use unicase::UniCase; use self::internals::{Item, VecMap, Entry}; -#[cfg(feature = "serde-serialization")] -use serde::{Deserialize, Deserializer, Serialize, Serializer}; -#[cfg(feature = "serde-serialization")] -use serde::de; -#[cfg(feature = "serde-serialization")] -use serde::ser; - pub use self::shared::*; pub use self::common::*; @@ -346,40 +339,6 @@ impl fmt::Debug for Headers { } } -#[cfg(feature = "serde-serialization")] -impl Serialize for Headers { - fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer { - serializer.serialize_map(ser::impls::MapIteratorVisitor::new( - self.iter().map(|header| (header.name(), header.value_string())), - Some(self.len()), - )) - } -} - -#[cfg(feature = "serde-serialization")] -impl Deserialize for Headers { - fn deserialize(deserializer: &mut D) -> Result where D: Deserializer { - struct HeadersVisitor; - - impl de::Visitor for HeadersVisitor { - type Value = Headers; - - fn visit_map(&mut self, mut visitor: V) -> Result - where V: de::MapVisitor { - let mut result = Headers::new(); - while let Some((key, value)) = try!(visitor.visit()) { - let (key, value): (String, String) = (key, value); - result.set_raw(key, vec![value.into_bytes()]); - } - try!(visitor.end()); - Ok(result) - } - } - - deserializer.deserialize_map(HeadersVisitor) - } -} - /// An `Iterator` over the fields in a `Headers` map. pub struct HeadersItems<'a> { inner: ::std::slice::Iter<'a, (HeaderName, Item)> diff --git a/src/http/mod.rs b/src/http/mod.rs index 396eec559d..729bc1a3d3 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -7,8 +7,6 @@ use header::Headers; use version::HttpVersion; use version::HttpVersion::{Http10, Http11}; -#[cfg(feature = "serde-serialization")] -use serde::{Deserialize, Deserializer, Serialize, Serializer}; pub use self::message::{HttpMessage, RequestHead, ResponseHead, Protocol}; @@ -20,21 +18,6 @@ pub mod message; #[derive(Clone, PartialEq, Debug)] pub struct RawStatus(pub u16, pub Cow<'static, str>); -#[cfg(feature = "serde-serialization")] -impl Serialize for RawStatus { - fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer { - (self.0, &self.1).serialize(serializer) - } -} - -#[cfg(feature = "serde-serialization")] -impl Deserialize for RawStatus { - fn deserialize(deserializer: &mut D) -> Result where D: Deserializer { - let representation: (u16, String) = try!(Deserialize::deserialize(deserializer)); - Ok(RawStatus(representation.0, Cow::Owned(representation.1))) - } -} - /// Checks if a connection should be kept alive. #[inline] pub fn should_keep_alive(version: HttpVersion, headers: &Headers) -> bool { diff --git a/src/lib.rs b/src/lib.rs index b580906768..0cdbabec1c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -131,8 +131,6 @@ extern crate rustc_serialize as serialize; extern crate time; #[macro_use] extern crate url; -#[cfg(feature = "serde-serialization")] -extern crate serde; extern crate cookie; extern crate unicase; extern crate httparse; diff --git a/src/method.rs b/src/method.rs index 10d5569119..ca7e5da277 100644 --- a/src/method.rs +++ b/src/method.rs @@ -7,8 +7,6 @@ use error::Error; use self::Method::{Options, Get, Post, Put, Delete, Head, Trace, Connect, Patch, Extension}; -#[cfg(feature = "serde-serialization")] -use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// The Request Method (VERB) /// @@ -128,21 +126,6 @@ impl fmt::Display for Method { } } -#[cfg(feature = "serde-serialization")] -impl Serialize for Method { - fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer { - format!("{}", self).serialize(serializer) - } -} - -#[cfg(feature = "serde-serialization")] -impl Deserialize for Method { - fn deserialize(deserializer: &mut D) -> Result where D: Deserializer { - let string_representation: String = try!(Deserialize::deserialize(deserializer)); - Ok(FromStr::from_str(&string_representation[..]).unwrap()) - } -} - #[cfg(test)] mod tests { use std::collections::HashMap;