5
5
#![ warn( missing_docs, missing_doc_code_examples) ]
6
6
#![ cfg_attr( test, deny( warnings) ) ]
7
7
8
+ use futures:: compat:: Future01CompatExt ;
8
9
#[ cfg( feature = "runtime" ) ]
9
10
use futures:: compat:: { Compat as Compat03As01 , Compat01As03 } ;
10
- use futures:: compat:: Future01CompatExt ;
11
11
use futures:: future:: BoxFuture ;
12
12
use futures:: prelude:: * ;
13
13
use futures:: stream;
14
14
use futures:: task:: Spawn ;
15
15
use http_service:: { Body , HttpService } ;
16
16
use hyper:: server:: { Builder as HyperBuilder , Server as HyperServer } ;
17
17
18
+ use std:: io;
18
19
#[ cfg( feature = "runtime" ) ]
19
20
use std:: net:: SocketAddr ;
20
21
use std:: pin:: Pin ;
21
22
use std:: sync:: Arc ;
22
23
use std:: task:: { self , Context , Poll } ;
23
- use std:: io;
24
24
25
25
// Wrapper type to allow us to provide a blanket `MakeService` impl
26
26
struct WrapHttpService < H > {
@@ -33,14 +33,14 @@ struct WrapConnection<H: HttpService> {
33
33
connection : H :: Connection ,
34
34
}
35
35
36
- impl < H , Ctx , > hyper:: service:: MakeService < Ctx > for WrapHttpService < H , >
36
+ impl < H , Ctx > hyper:: service:: MakeService < Ctx > for WrapHttpService < H >
37
37
where
38
38
H : HttpService ,
39
39
{
40
40
type ReqBody = hyper:: Body ;
41
41
type ResBody = hyper:: Body ;
42
42
type Error = std:: io:: Error ;
43
- type Service = WrapConnection < H , > ;
43
+ type Service = WrapConnection < H > ;
44
44
type Future = Compat03As01 < BoxFuture < ' static , Result < Self :: Service , Self :: Error > > > ;
45
45
type MakeError = std:: io:: Error ;
46
46
@@ -59,14 +59,15 @@ where
59
59
}
60
60
}
61
61
62
- impl < H , > hyper:: service:: Service for WrapConnection < H , >
62
+ impl < H > hyper:: service:: Service for WrapConnection < H >
63
63
where
64
64
H : HttpService ,
65
65
{
66
66
type ReqBody = hyper:: Body ;
67
67
type ResBody = hyper:: Body ;
68
68
type Error = std:: io:: Error ;
69
- type Future = Compat03As01 < BoxFuture < ' static , Result < http:: Response < hyper:: Body > , Self :: Error > > > ;
69
+ type Future =
70
+ Compat03As01 < BoxFuture < ' static , Result < http:: Response < hyper:: Body > , Self :: Error > > > ;
70
71
71
72
fn call ( & mut self , req : http:: Request < hyper:: Body > ) -> Self :: Future {
72
73
// Convert Request
87
88
let ( parts, body) = res. into_parts ( ) ;
88
89
let body = hyper:: Body :: wrap_stream ( Compat03As01 :: new ( ChunkStream { body } ) ) ;
89
90
Ok ( hyper:: Response :: from_parts ( parts, body) )
90
- } . boxed ( ) . compat ( )
91
+ }
92
+ . boxed ( )
93
+ . compat ( )
91
94
}
92
95
}
93
96
@@ -116,7 +119,10 @@ impl<I: TryStream, S, Sp> std::fmt::Debug for Server<I, S, Sp> {
116
119
/// A builder for a [`Server`].
117
120
#[ allow( clippy:: type_complexity) ] // single-use type with many compat layers
118
121
pub struct Builder < I : TryStream , Sp > {
119
- inner : HyperBuilder < Compat03As01 < stream:: MapOk < I , fn ( I :: Ok ) -> Compat03As01 < I :: Ok > > > , Compat03As01 < Sp > > ,
122
+ inner : HyperBuilder <
123
+ Compat03As01 < stream:: MapOk < I , fn ( I :: Ok ) -> Compat03As01 < I :: Ok > > > ,
124
+ Compat03As01 < Sp > ,
125
+ > ,
120
126
}
121
127
122
128
impl < I : TryStream , Sp > std:: fmt:: Debug for Builder < I , Sp > {
@@ -170,7 +176,7 @@ impl<I: TryStream, Sp> Builder<I, Sp> {
170
176
/// // Finally, spawn `server` onto our executor...
171
177
/// pool.run(server)?;
172
178
/// # Ok::<(), Box<dyn std::error::Error>>(())
173
- pub fn serve < S : HttpService , > ( self , service : S ) -> Server < I , S , Sp >
179
+ pub fn serve < S : HttpService > ( self , service : S ) -> Server < I , S , Sp >
174
180
where
175
181
I : TryStream + Unpin ,
176
182
I :: Ok : AsyncRead + AsyncWrite + Send + Unpin + ' static ,
@@ -186,7 +192,7 @@ impl<I: TryStream, Sp> Builder<I, Sp> {
186
192
}
187
193
}
188
194
189
- impl < I , S , Sp , > Future for Server < I , S , Sp >
195
+ impl < I , S , Sp > Future for Server < I , S , Sp >
190
196
where
191
197
I : TryStream + Unpin ,
192
198
I :: Ok : AsyncRead + AsyncWrite + Send + Unpin + ' static ,
@@ -205,7 +211,7 @@ where
205
211
/// Serve the given `HttpService` at the given address, using `hyper` as backend, and return a
206
212
/// `Future` that can be `await`ed on.
207
213
#[ cfg( feature = "runtime" ) ]
208
- pub fn serve < S : HttpService , > (
214
+ pub fn serve < S : HttpService > (
209
215
s : S ,
210
216
addr : SocketAddr ,
211
217
) -> impl Future < Output = Result < ( ) , hyper:: Error > > {
0 commit comments