1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-31 00:50:20 +02:00

add String and Bytes extractor

This commit is contained in:
Nikolay Kim
2018-04-02 16:19:18 -07:00
parent ef6f310060
commit d292c5023f
6 changed files with 167 additions and 72 deletions

View File

@@ -1,5 +1,6 @@
use std::ops::Deref;
use std::marker::PhantomData;
use futures::Poll;
use futures::future::{Future, FutureResult, ok, err};
use error::Error;
@@ -96,6 +97,21 @@ impl<A, B> Responder for Either<A, B>
}
}
impl<A, B, I, E> Future for Either<A, B>
where A: Future<Item=I, Error=E>,
B: Future<Item=I, Error=E>,
{
type Item = I;
type Error = E;
fn poll(&mut self) -> Poll<I, E> {
match *self {
Either::A(ref mut fut) => fut.poll(),
Either::B(ref mut fut) => fut.poll(),
}
}
}
/// Convenience trait that converts `Future` object to a `Boxed` future
///
/// For example loading json from request's body is async operation.