tower_web/util/http/
future.rs1use futures::{Future, Poll};
2use http;
3
4pub trait HttpFuture: sealed::Sealed {
11 type Body;
13
14 fn poll_http(&mut self) -> Poll<http::Response<Self::Body>, ::Error>;
17
18 fn lift(self) -> LiftFuture<Self>
21 where Self: Sized,
22 {
23 LiftFuture { inner: self }
24 }
25}
26
27#[derive(Debug)]
29pub struct LiftFuture<T> {
30 inner: T,
31}
32
33impl<T, B> HttpFuture for T
34where T: Future<Item = http::Response<B>, Error = ::Error>
35{
36 type Body = B;
37
38 fn poll_http(&mut self) -> Poll<http::Response<Self::Body>, ::Error> {
39 Future::poll(self)
40 }
41}
42
43impl<T, B> sealed::Sealed for T
44where T: Future<Item = http::Response<B>, Error = ::Error>
45{
46}
47
48impl<T: HttpFuture> Future for LiftFuture<T> {
49 type Item = http::Response<T::Body>;
50 type Error = ::Error;
51
52 fn poll(&mut self) -> Poll<Self::Item, ::Error> {
53 self.inner.poll_http()
54 }
55}
56
57pub(crate) mod sealed {
59 pub trait Sealed {}
60}