feat(lib): redesign API to use Futures and Tokio
There are many changes involved with this, but let's just talk about
user-facing changes.
- Creating a `Client` and `Server` now needs a Tokio `Core` event loop
to attach to.
- `Request` and `Response` both no longer implement the
`std::io::{Read,Write}` traits, but instead represent their bodies as a
`futures::Stream` of items, where each item is a `Chunk`.
- The `Client.request` method now takes a `Request`, instead of being
used as a builder, and returns a `Future` that resolves to `Response`.
- The `Handler` trait for servers is no more, and instead the Tokio
`Service` trait is used. This allows interoperability with generic
middleware.
BREAKING CHANGE: A big sweeping set of breaking changes.
This commit is contained in:
@@ -182,31 +182,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<S>(&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<D>(deserializer: &mut D) -> Result<$id, D::Error>
|
||||
where D: ::serde::Deserializer {
|
||||
let string_representation: String =
|
||||
try!(::serde::Deserialize::deserialize(deserializer));
|
||||
let raw = string_representation.into_bytes().into();
|
||||
Ok($crate::header::Header::parse_header(&raw).unwrap())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! header {
|
||||
// $a:meta: Attributes associated with the header item (usually docs)
|
||||
@@ -238,8 +213,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)+) => {
|
||||
@@ -265,7 +238,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 +262,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)+}) => {
|
||||
@@ -330,7 +301,6 @@ macro_rules! header {
|
||||
self.fmt_header(f)
|
||||
}
|
||||
}
|
||||
__hyper_generate_header_serialization!($id);
|
||||
};
|
||||
|
||||
// optional test module
|
||||
@@ -421,4 +391,4 @@ mod transfer_encoding;
|
||||
mod upgrade;
|
||||
mod user_agent;
|
||||
mod vary;
|
||||
mod warning;
|
||||
mod warning;
|
||||
|
||||
Reference in New Issue
Block a user