@@ -18,7 +18,7 @@ type TrailersSender = oneshot::Sender<HeaderMap>;
18
18
19
19
/// A stream of `Bytes`, used when receiving bodies from the network.
20
20
#[ must_use = "streams do nothing unless polled" ]
21
- pub struct Recv {
21
+ pub struct Incoming {
22
22
kind : Kind ,
23
23
}
24
24
@@ -65,17 +65,17 @@ pub(crate) struct Sender {
65
65
const WANT_PENDING : usize = 1 ;
66
66
const WANT_READY : usize = 2 ;
67
67
68
- impl Recv {
68
+ impl Incoming {
69
69
/// Create a `Body` stream with an associated sender half.
70
70
///
71
71
/// Useful when wanting to stream chunks from another thread.
72
72
#[ inline]
73
73
#[ allow( unused) ]
74
- pub ( crate ) fn channel ( ) -> ( Sender , Recv ) {
74
+ pub ( crate ) fn channel ( ) -> ( Sender , Incoming ) {
75
75
Self :: new_channel ( DecodedLength :: CHUNKED , /*wanter =*/ false )
76
76
}
77
77
78
- pub ( crate ) fn new_channel ( content_length : DecodedLength , wanter : bool ) -> ( Sender , Recv ) {
78
+ pub ( crate ) fn new_channel ( content_length : DecodedLength , wanter : bool ) -> ( Sender , Incoming ) {
79
79
let ( data_tx, data_rx) = mpsc:: channel ( 0 ) ;
80
80
let ( trailers_tx, trailers_rx) = oneshot:: channel ( ) ;
81
81
@@ -90,7 +90,7 @@ impl Recv {
90
90
data_tx,
91
91
trailers_tx : Some ( trailers_tx) ,
92
92
} ;
93
- let rx = Recv :: new ( Kind :: Chan {
93
+ let rx = Incoming :: new ( Kind :: Chan {
94
94
content_length,
95
95
want_tx,
96
96
data_rx,
@@ -100,18 +100,18 @@ impl Recv {
100
100
( tx, rx)
101
101
}
102
102
103
- fn new ( kind : Kind ) -> Recv {
104
- Recv { kind }
103
+ fn new ( kind : Kind ) -> Incoming {
104
+ Incoming { kind }
105
105
}
106
106
107
107
#[ allow( dead_code) ]
108
- pub ( crate ) fn empty ( ) -> Recv {
109
- Recv :: new ( Kind :: Empty )
108
+ pub ( crate ) fn empty ( ) -> Incoming {
109
+ Incoming :: new ( Kind :: Empty )
110
110
}
111
111
112
112
#[ cfg( feature = "ffi" ) ]
113
- pub ( crate ) fn ffi ( ) -> Recv {
114
- Recv :: new ( Kind :: Ffi ( crate :: ffi:: UserBody :: new ( ) ) )
113
+ pub ( crate ) fn ffi ( ) -> Incoming {
114
+ Incoming :: new ( Kind :: Ffi ( crate :: ffi:: UserBody :: new ( ) ) )
115
115
}
116
116
117
117
#[ cfg( all( feature = "http2" , any( feature = "client" , feature = "server" ) ) ) ]
@@ -125,7 +125,7 @@ impl Recv {
125
125
if !content_length. is_exact ( ) && recv. is_end_stream ( ) {
126
126
content_length = DecodedLength :: ZERO ;
127
127
}
128
- let body = Recv :: new ( Kind :: H2 {
128
+ let body = Incoming :: new ( Kind :: H2 {
129
129
data_done : false ,
130
130
ping,
131
131
content_length,
@@ -151,7 +151,7 @@ impl Recv {
151
151
}
152
152
}
153
153
154
- impl Body for Recv {
154
+ impl Body for Incoming {
155
155
type Data = Bytes ;
156
156
type Error = crate :: Error ;
157
157
@@ -259,7 +259,7 @@ impl Body for Recv {
259
259
}
260
260
}
261
261
262
- impl fmt:: Debug for Recv {
262
+ impl fmt:: Debug for Incoming {
263
263
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
264
264
#[ derive( Debug ) ]
265
265
struct Streaming ;
@@ -375,15 +375,15 @@ mod tests {
375
375
use std:: mem;
376
376
use std:: task:: Poll ;
377
377
378
- use super :: { Body , DecodedLength , Recv , Sender , SizeHint } ;
378
+ use super :: { Body , DecodedLength , Incoming , Sender , SizeHint } ;
379
379
use http_body_util:: BodyExt ;
380
380
381
381
#[ test]
382
382
fn test_size_of ( ) {
383
383
// These are mostly to help catch *accidentally* increasing
384
384
// the size by too much.
385
385
386
- let body_size = mem:: size_of :: < Recv > ( ) ;
386
+ let body_size = mem:: size_of :: < Incoming > ( ) ;
387
387
let body_expected_size = mem:: size_of :: < u64 > ( ) * 5 ;
388
388
assert ! (
389
389
body_size <= body_expected_size,
@@ -392,7 +392,7 @@ mod tests {
392
392
body_expected_size,
393
393
) ;
394
394
395
- //assert_eq!(body_size, mem::size_of::<Option<Recv >>(), "Option<Recv >");
395
+ //assert_eq!(body_size, mem::size_of::<Option<Incoming >>(), "Option<Incoming >");
396
396
397
397
assert_eq ! (
398
398
mem:: size_of:: <Sender >( ) ,
@@ -409,18 +409,18 @@ mod tests {
409
409
410
410
#[ test]
411
411
fn size_hint ( ) {
412
- fn eq ( body : Recv , b : SizeHint , note : & str ) {
412
+ fn eq ( body : Incoming , b : SizeHint , note : & str ) {
413
413
let a = body. size_hint ( ) ;
414
414
assert_eq ! ( a. lower( ) , b. lower( ) , "lower for {:?}" , note) ;
415
415
assert_eq ! ( a. upper( ) , b. upper( ) , "upper for {:?}" , note) ;
416
416
}
417
417
418
- eq ( Recv :: empty ( ) , SizeHint :: with_exact ( 0 ) , "empty" ) ;
418
+ eq ( Incoming :: empty ( ) , SizeHint :: with_exact ( 0 ) , "empty" ) ;
419
419
420
- eq ( Recv :: channel ( ) . 1 , SizeHint :: new ( ) , "channel" ) ;
420
+ eq ( Incoming :: channel ( ) . 1 , SizeHint :: new ( ) , "channel" ) ;
421
421
422
422
eq (
423
- Recv :: new_channel ( DecodedLength :: new ( 4 ) , /*wanter =*/ false ) . 1 ,
423
+ Incoming :: new_channel ( DecodedLength :: new ( 4 ) , /*wanter =*/ false ) . 1 ,
424
424
SizeHint :: with_exact ( 4 ) ,
425
425
"channel with length" ,
426
426
) ;
@@ -429,7 +429,7 @@ mod tests {
429
429
#[ cfg( not( miri) ) ]
430
430
#[ tokio:: test]
431
431
async fn channel_abort ( ) {
432
- let ( tx, mut rx) = Recv :: channel ( ) ;
432
+ let ( tx, mut rx) = Incoming :: channel ( ) ;
433
433
434
434
tx. abort ( ) ;
435
435
@@ -440,7 +440,7 @@ mod tests {
440
440
#[ cfg( all( not( miri) , feature = "http1" ) ) ]
441
441
#[ tokio:: test]
442
442
async fn channel_abort_when_buffer_is_full ( ) {
443
- let ( mut tx, mut rx) = Recv :: channel ( ) ;
443
+ let ( mut tx, mut rx) = Incoming :: channel ( ) ;
444
444
445
445
tx. try_send_data ( "chunk 1" . into ( ) ) . expect ( "send 1" ) ;
446
446
// buffer is full, but can still send abort
@@ -462,7 +462,7 @@ mod tests {
462
462
#[ cfg( feature = "http1" ) ]
463
463
#[ test]
464
464
fn channel_buffers_one ( ) {
465
- let ( mut tx, _rx) = Recv :: channel ( ) ;
465
+ let ( mut tx, _rx) = Incoming :: channel ( ) ;
466
466
467
467
tx. try_send_data ( "chunk 1" . into ( ) ) . expect ( "send 1" ) ;
468
468
@@ -474,14 +474,14 @@ mod tests {
474
474
#[ cfg( not( miri) ) ]
475
475
#[ tokio:: test]
476
476
async fn channel_empty ( ) {
477
- let ( _, mut rx) = Recv :: channel ( ) ;
477
+ let ( _, mut rx) = Incoming :: channel ( ) ;
478
478
479
479
assert ! ( rx. frame( ) . await . is_none( ) ) ;
480
480
}
481
481
482
482
#[ test]
483
483
fn channel_ready ( ) {
484
- let ( mut tx, _rx) = Recv :: new_channel ( DecodedLength :: CHUNKED , /*wanter = */ false ) ;
484
+ let ( mut tx, _rx) = Incoming :: new_channel ( DecodedLength :: CHUNKED , /*wanter = */ false ) ;
485
485
486
486
let mut tx_ready = tokio_test:: task:: spawn ( tx. ready ( ) ) ;
487
487
@@ -490,7 +490,8 @@ mod tests {
490
490
491
491
#[ test]
492
492
fn channel_wanter ( ) {
493
- let ( mut tx, mut rx) = Recv :: new_channel ( DecodedLength :: CHUNKED , /*wanter = */ true ) ;
493
+ let ( mut tx, mut rx) =
494
+ Incoming :: new_channel ( DecodedLength :: CHUNKED , /*wanter = */ true ) ;
494
495
495
496
let mut tx_ready = tokio_test:: task:: spawn ( tx. ready ( ) ) ;
496
497
let mut rx_data = tokio_test:: task:: spawn ( rx. frame ( ) ) ;
@@ -511,7 +512,7 @@ mod tests {
511
512
512
513
#[ test]
513
514
fn channel_notices_closure ( ) {
514
- let ( mut tx, rx) = Recv :: new_channel ( DecodedLength :: CHUNKED , /*wanter = */ true ) ;
515
+ let ( mut tx, rx) = Incoming :: new_channel ( DecodedLength :: CHUNKED , /*wanter = */ true ) ;
515
516
516
517
let mut tx_ready = tokio_test:: task:: spawn ( tx. ready ( ) ) ;
517
518
0 commit comments