2
2
3
3
use std:: error:: Error as StdError ;
4
4
use std:: fmt;
5
- use std:: marker:: PhantomData ;
6
5
use std:: sync:: Arc ;
7
6
use std:: time:: Duration ;
8
7
9
8
use bytes:: Bytes ;
10
9
use tokio:: io:: { AsyncRead , AsyncWrite } ;
11
10
12
11
use crate :: body:: { Body , Recv } ;
13
- use crate :: common:: exec:: { ConnStreamExec , Exec } ;
14
12
use crate :: common:: { task, Future , Pin , Poll , Unpin } ;
15
13
use crate :: { common:: time:: Time , rt:: Timer } ;
16
14
use crate :: proto;
@@ -25,21 +23,18 @@ pin_project_lite::pin_project! {
25
23
///
26
24
/// Polling this future will drive HTTP forward.
27
25
#[ must_use = "futures do nothing unless polled" ]
28
- pub struct Connection <T , S , E >
26
+ pub struct Connection <T , S >
29
27
where
30
28
S : HttpService <Recv >,
31
29
{
32
30
conn: Option <Http1Dispatcher <T , S :: ResBody , S >>,
33
- // can we remove this?
34
- _exec: PhantomData <E >,
35
31
}
36
32
}
37
33
38
34
39
35
/// A configuration builder for HTTP/1 server connections.
40
36
#[ derive( Clone , Debug ) ]
41
- pub struct Builder < E = Exec > {
42
- pub ( crate ) _exec : E ,
37
+ pub struct Builder {
43
38
pub ( crate ) timer : Time ,
44
39
h1_half_close : bool ,
45
40
h1_keep_alive : bool ,
@@ -75,7 +70,7 @@ pub struct Parts<T, S> {
75
70
76
71
// ===== impl Connection =====
77
72
78
- impl < I , S , E > fmt:: Debug for Connection < I , S , E >
73
+ impl < I , S > fmt:: Debug for Connection < I , S >
79
74
where
80
75
S : HttpService < Recv > ,
81
76
{
@@ -84,14 +79,13 @@ where
84
79
}
85
80
}
86
81
87
- impl < I , B , S , E > Connection < I , S , E >
82
+ impl < I , B , S > Connection < I , S >
88
83
where
89
84
S : HttpService < Recv , ResBody = B > ,
90
85
S :: Error : Into < Box < dyn StdError + Send + Sync > > ,
91
86
I : AsyncRead + AsyncWrite + Unpin ,
92
87
B : Body + ' static ,
93
88
B :: Error : Into < Box < dyn StdError + Send + Sync > > ,
94
- E : ConnStreamExec < S :: Future , B > ,
95
89
{
96
90
/// Start a graceful shutdown process for this connection.
97
91
///
@@ -187,7 +181,7 @@ where
187
181
/// Enable this connection to support higher-level HTTP upgrades.
188
182
///
189
183
/// See [the `upgrade` module](crate::upgrade) for more.
190
- pub fn with_upgrades ( self ) -> upgrades:: UpgradeableConnection < I , S , E >
184
+ pub fn with_upgrades ( self ) -> upgrades:: UpgradeableConnection < I , S >
191
185
where
192
186
I : Send ,
193
187
{
@@ -196,14 +190,13 @@ where
196
190
}
197
191
198
192
199
- impl < I , B , S , E > Future for Connection < I , S , E >
193
+ impl < I , B , S > Future for Connection < I , S >
200
194
where
201
195
S : HttpService < Recv , ResBody = B > ,
202
196
S :: Error : Into < Box < dyn StdError + Send + Sync > > ,
203
197
I : AsyncRead + AsyncWrite + Unpin + ' static ,
204
198
B : Body + ' static ,
205
199
B :: Error : Into < Box < dyn StdError + Send + Sync > > ,
206
- E : ConnStreamExec < S :: Future , B > ,
207
200
{
208
201
type Output = crate :: Result < ( ) > ;
209
202
@@ -229,13 +222,10 @@ where
229
222
230
223
// ===== impl Builder =====
231
224
232
- impl < E > Builder < E > {
225
+ impl Builder {
233
226
/// Create a new connection builder.
234
- ///
235
- /// This starts with the default options, and an executor.
236
- pub fn new ( exec : E ) -> Self {
227
+ pub fn new ( ) -> Self {
237
228
Self {
238
- _exec : exec,
239
229
timer : Time :: Empty ,
240
230
h1_half_close : false ,
241
231
h1_keep_alive : true ,
@@ -351,24 +341,6 @@ impl<E> Builder<E> {
351
341
self
352
342
}
353
343
354
- /// Set the executor used to spawn background tasks.
355
- ///
356
- /// Default uses implicit default (like `tokio::spawn`).
357
- pub fn with_executor < E2 > ( self , exec : E2 ) -> Builder < E2 > {
358
- Builder {
359
- _exec : exec,
360
- timer : self . timer ,
361
- h1_half_close : self . h1_half_close ,
362
- h1_keep_alive : self . h1_keep_alive ,
363
- h1_title_case_headers : self . h1_title_case_headers ,
364
- h1_preserve_header_case : self . h1_preserve_header_case ,
365
- h1_header_read_timeout : self . h1_header_read_timeout ,
366
- h1_writev : self . h1_writev ,
367
- max_buf_size : self . max_buf_size ,
368
- pipeline_flush : self . pipeline_flush ,
369
- }
370
- }
371
-
372
344
/// Set the timer used in background tasks.
373
345
pub fn timer < M > ( & mut self , timer : M ) -> & mut Self
374
346
where
@@ -388,7 +360,7 @@ impl<E> Builder<E> {
388
360
/// ```
389
361
/// # use hyper::{Recv, Request, Response};
390
362
/// # use hyper::service::Service;
391
- /// # use hyper::server::conn::Http ;
363
+ /// # use hyper::server::conn::http1::Builder ;
392
364
/// # use tokio::io::{AsyncRead, AsyncWrite};
393
365
/// # async fn run<I, S>(some_io: I, some_service: S)
394
366
/// # where
@@ -397,7 +369,7 @@ impl<E> Builder<E> {
397
369
/// # S::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
398
370
/// # S::Future: Send,
399
371
/// # {
400
- /// let http = Http ::new();
372
+ /// let http = Builder ::new();
401
373
/// let conn = http.serve_connection(some_io, some_service);
402
374
///
403
375
/// if let Err(e) = conn.await {
@@ -406,14 +378,13 @@ impl<E> Builder<E> {
406
378
/// # }
407
379
/// # fn main() {}
408
380
/// ```
409
- pub fn serve_connection < S , I , Bd > ( & self , io : I , service : S ) -> Connection < I , S , E >
381
+ pub fn serve_connection < I , S > ( & self , io : I , service : S ) -> Connection < I , S >
410
382
where
411
- S : HttpService < Recv , ResBody = Bd > ,
383
+ S : HttpService < Recv > ,
412
384
S :: Error : Into < Box < dyn StdError + Send + Sync > > ,
413
- Bd : Body + ' static ,
414
- Bd :: Error : Into < Box < dyn StdError + Send + Sync > > ,
385
+ S :: ResBody : ' static ,
386
+ < S :: ResBody as Body > :: Error : Into < Box < dyn StdError + Send + Sync > > ,
415
387
I : AsyncRead + AsyncWrite + Unpin ,
416
- E : ConnStreamExec < S :: Future , Bd > ,
417
388
{
418
389
let mut conn = proto:: Conn :: new ( io) ;
419
390
conn. set_timer ( self . timer . clone ( ) ) ;
@@ -447,7 +418,6 @@ impl<E> Builder<E> {
447
418
let proto = proto:: h1:: Dispatcher :: new ( sd, conn) ;
448
419
Connection {
449
420
conn : Some ( proto) ,
450
- _exec : PhantomData ,
451
421
}
452
422
}
453
423
}
@@ -459,25 +429,23 @@ mod upgrades {
459
429
460
430
// A future binding a connection with a Service with Upgrade support.
461
431
//
462
- // This type is unnameable outside the crate, and so basically just an
463
- // `impl Future`, without requiring Rust 1.26.
432
+ // This type is unnameable outside the crate.
464
433
#[ must_use = "futures do nothing unless polled" ]
465
434
#[ allow( missing_debug_implementations) ]
466
- pub struct UpgradeableConnection < T , S , E >
435
+ pub struct UpgradeableConnection < T , S >
467
436
where
468
437
S : HttpService < Recv > ,
469
438
{
470
- pub ( super ) inner : Connection < T , S , E > ,
439
+ pub ( super ) inner : Connection < T , S > ,
471
440
}
472
441
473
- impl < I , B , S , E > UpgradeableConnection < I , S , E >
442
+ impl < I , B , S > UpgradeableConnection < I , S >
474
443
where
475
444
S : HttpService < Recv , ResBody = B > ,
476
445
S :: Error : Into < Box < dyn StdError + Send + Sync > > ,
477
446
I : AsyncRead + AsyncWrite + Unpin ,
478
447
B : Body + ' static ,
479
448
B :: Error : Into < Box < dyn StdError + Send + Sync > > ,
480
- E : ConnStreamExec < S :: Future , B > ,
481
449
{
482
450
/// Start a graceful shutdown process for this connection.
483
451
///
@@ -488,14 +456,13 @@ mod upgrades {
488
456
}
489
457
}
490
458
491
- impl < I , B , S , E > Future for UpgradeableConnection < I , S , E >
459
+ impl < I , B , S > Future for UpgradeableConnection < I , S >
492
460
where
493
461
S : HttpService < Recv , ResBody = B > ,
494
462
S :: Error : Into < Box < dyn StdError + Send + Sync > > ,
495
463
I : AsyncRead + AsyncWrite + Unpin + Send + ' static ,
496
464
B : Body + ' static ,
497
465
B :: Error : Into < Box < dyn StdError + Send + Sync > > ,
498
- E : ConnStreamExec < S :: Future , B > ,
499
466
{
500
467
type Output = crate :: Result < ( ) > ;
501
468
0 commit comments