1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use super::HttpService;
use util::buf_stream::BufStream;
use futures::Future;
use http::{Request, Response};
use tower_service::NewService;
pub trait NewHttpService: sealed::Sealed {
type RequestBody: BufStream;
type ResponseBody: BufStream;
type Error;
type Service: HttpService<RequestBody = Self::RequestBody,
ResponseBody = Self::ResponseBody,
Error = Self::Error>;
type InitError;
type Future: Future<Item = Self::Service, Error = Self::InitError>;
fn new_http_service(&self) -> Self::Future;
}
impl<T, B1, B2> NewHttpService for T
where T: NewService<Request = Request<B1>,
Response = Response<B2>>,
B1: BufStream,
B2: BufStream
{
type RequestBody = B1;
type ResponseBody = B2;
type Error = T::Error;
type Service = T::Service;
type InitError = T::InitError;
type Future = T::Future;
fn new_http_service(&self) -> Self::Future {
NewService::new_service(self)
}
}
impl<T, B1, B2> sealed::Sealed for T
where T: NewService<Request = Request<B1>,
Response = Response<B2>>,
B1: BufStream,
B2: BufStream
{}
mod sealed {
pub trait Sealed {}
}