tower_http_util/
connection.rs1use futures::{Future, Poll};
7use http_connection::HttpConnection;
8use tokio_io::{AsyncRead, AsyncWrite};
9use tower_service::Service;
10
11pub trait HttpMakeConnection<Target>: sealed::Sealed<Target> {
16 type Connection: HttpConnection + AsyncRead + AsyncWrite;
18
19 type Error;
21
22 type Future: Future<Item = Self::Connection, Error = Self::Error>;
24
25 fn poll_ready(&mut self) -> Poll<(), Self::Error>;
27
28 fn make_connection(&mut self, target: Target) -> Self::Future;
30}
31
32impl<C, Target> sealed::Sealed<Target> for C where C: Service<Target> {}
33
34impl<C, Target> HttpMakeConnection<Target> for C
35where
36 C: Service<Target>,
37 C::Response: HttpConnection + AsyncRead + AsyncWrite,
38{
39 type Connection = C::Response;
40 type Error = C::Error;
41 type Future = C::Future;
42
43 fn poll_ready(&mut self) -> Poll<(), Self::Error> {
44 Service::poll_ready(self)
45 }
46
47 fn make_connection(&mut self, target: Target) -> Self::Future {
48 Service::call(self, target)
49 }
50}
51
52mod sealed {
53 pub trait Sealed<Target> {}
54}