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:
@@ -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)
|
||||
///
|
||||
@@ -134,21 +132,6 @@ impl Default for Method {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde-serialization")]
|
||||
impl Serialize for Method {
|
||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer {
|
||||
format!("{}", self).serialize(serializer)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde-serialization")]
|
||||
impl Deserialize for Method {
|
||||
fn deserialize<D>(deserializer: &mut D) -> Result<Method, D::Error> 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;
|
||||
|
||||
Reference in New Issue
Block a user