@@ -2,7 +2,7 @@ use std::fmt;
2
2
use std:: io:: { self , Write } ;
3
3
use std:: marker:: PhantomData ;
4
4
5
- use futures:: { Poll , Async , AsyncSink , Stream , Sink , StartSend } ;
5
+ use futures:: { Poll , Async , AsyncSink , Future , Stream , Sink , StartSend } ;
6
6
use futures:: task:: Task ;
7
7
use tokio_io:: { AsyncRead , AsyncWrite } ;
8
8
use tokio_proto:: streaming:: pipeline:: { Frame , Transport } ;
@@ -21,21 +21,23 @@ use version::HttpVersion;
21
21
/// The connection will determine when a message begins and ends as well as
22
22
/// determine if this connection can be kept alive after the message,
23
23
/// or if it is complete.
24
- pub struct Conn < I , B , T , K = KA > {
24
+ pub struct Conn < I , B , T , O , K = KA > {
25
25
io : Buffered < I > ,
26
+ onion : O ,
26
27
state : State < B , K > ,
27
28
_marker : PhantomData < T >
28
29
}
29
30
30
- impl < I , B , T , K > Conn < I , B , T , K >
31
+ impl < I , B , T , O , K > Conn < I , B , T , O , K >
31
32
where I : AsyncRead + AsyncWrite ,
32
33
B : AsRef < [ u8 ] > ,
33
34
T : Http1Transaction ,
34
35
K : KeepAlive
35
36
{
36
- pub fn new ( io : I , keep_alive : K ) -> Conn < I , B , T , K > {
37
+ pub fn new ( io : I , keep_alive : K , onion : O ) -> Conn < I , B , T , O , K > {
37
38
Conn {
38
39
io : Buffered :: new ( io) ,
40
+ onion : onion,
39
41
state : State {
40
42
keep_alive : keep_alive,
41
43
method : None ,
@@ -51,8 +53,8 @@ where I: AsyncRead + AsyncWrite,
51
53
self . io . set_flush_pipeline ( enabled) ;
52
54
}
53
55
54
- fn poll2 ( & mut self ) -> Poll < Option < Frame < super :: MessageHead < T :: Incoming > , super :: Chunk , :: Error > > , io:: Error > {
55
- trace ! ( "Conn::poll ()" ) ;
56
+ fn poll_incoming ( & mut self ) -> Poll < Option < Frame < super :: MessageHead < T :: Incoming > , super :: Chunk , :: Error > > , io:: Error > {
57
+ trace ! ( "Conn::poll_incoming ()" ) ;
56
58
57
59
loop {
58
60
if self . is_read_closed ( ) {
@@ -412,7 +414,30 @@ where I: AsyncRead + AsyncWrite,
412
414
}
413
415
}
414
416
415
- impl < I , B , T , K > Stream for Conn < I , B , T , K >
417
+ // ==== future impl ====
418
+
419
+ pub struct NoOnion ;
420
+
421
+ impl < I , B , T , K > Future for Conn < I , B , T , NoOnion , K >
422
+ where I : AsyncRead + AsyncWrite ,
423
+ B : AsRef < [ u8 ] > ,
424
+ T : Http1Transaction ,
425
+ K : KeepAlive ,
426
+ T :: Outgoing : fmt:: Debug {
427
+ type Item = I ;
428
+ type Error = :: Error ;
429
+
430
+ #[ inline]
431
+ fn poll ( & mut self ) -> Poll < Self :: Item , Self :: Error > {
432
+ unimplemented ! ( "future impl" )
433
+ }
434
+ }
435
+
436
+ // ==== tokio_proto impl ====
437
+
438
+ pub struct ProtoOnion ;
439
+
440
+ impl < I , B , T , K > Stream for Conn < I , B , T , ProtoOnion , K >
416
441
where I : AsyncRead + AsyncWrite ,
417
442
B : AsRef < [ u8 ] > ,
418
443
T : Http1Transaction ,
@@ -423,14 +448,14 @@ where I: AsyncRead + AsyncWrite,
423
448
424
449
#[ inline]
425
450
fn poll ( & mut self ) -> Poll < Option < Self :: Item > , Self :: Error > {
426
- self . poll2 ( ) . map_err ( |err| {
451
+ self . poll_incoming ( ) . map_err ( |err| {
427
452
debug ! ( "poll error: {}" , err) ;
428
453
err
429
454
} )
430
455
}
431
456
}
432
457
433
- impl < I , B , T , K > Sink for Conn < I , B , T , K >
458
+ impl < I , B , T , K > Sink for Conn < I , B , T , ProtoOnion , K >
434
459
where I : AsyncRead + AsyncWrite ,
435
460
B : AsRef < [ u8 ] > ,
436
461
T : Http1Transaction ,
@@ -501,14 +526,14 @@ where I: AsyncRead + AsyncWrite,
501
526
}
502
527
}
503
528
504
- impl <I , B , T , K > Transport for Conn < I , B , T , K >
529
+ impl <I , B , T , K > Transport for Conn < I , B , T , ProtoOnion , K >
505
530
where I : AsyncRead + AsyncWrite + ' static ,
506
531
B : AsRef < [ u8 ] > + ' static ,
507
532
T : Http1Transaction + ' static ,
508
533
K : KeepAlive + ' static ,
509
534
T :: Outgoing : fmt:: Debug { }
510
535
511
- impl< I , B : AsRef < [ u8 ] > , T , K : fmt:: Debug > fmt:: Debug for Conn < I , B , T , K > {
536
+ impl< I , B : AsRef < [ u8 ] > , T , O , K : fmt:: Debug > fmt:: Debug for Conn < I , B , T , O , K > {
512
537
fn fmt( & self , f: & mut fmt:: Formatter ) -> fmt:: Result {
513
538
f. debug_struct( "Conn" )
514
539
. field( "state" , & self . state)
0 commit comments