@@ -24,7 +24,7 @@ type TrailersSender = oneshot::Sender<HeaderMap>;
24
24
/// Note: To read the full body, use [`body::to_bytes`](crate::body::to_bytes)
25
25
/// or [`body::aggregate`](crate::body::aggregate).
26
26
#[ must_use = "streams do nothing unless polled" ]
27
- pub struct Body {
27
+ pub struct Recv {
28
28
kind : Kind ,
29
29
}
30
30
@@ -70,16 +70,16 @@ pub struct Sender {
70
70
const WANT_PENDING : usize = 1 ;
71
71
const WANT_READY : usize = 2 ;
72
72
73
- impl Body {
73
+ impl Recv {
74
74
/// Create a `Body` stream with an associated sender half.
75
75
///
76
76
/// Useful when wanting to stream chunks from another thread.
77
77
#[ inline]
78
- pub fn channel ( ) -> ( Sender , Body ) {
78
+ pub fn channel ( ) -> ( Sender , Recv ) {
79
79
Self :: new_channel ( DecodedLength :: CHUNKED , /*wanter =*/ false )
80
80
}
81
81
82
- pub ( crate ) fn new_channel ( content_length : DecodedLength , wanter : bool ) -> ( Sender , Body ) {
82
+ pub ( crate ) fn new_channel ( content_length : DecodedLength , wanter : bool ) -> ( Sender , Recv ) {
83
83
let ( data_tx, data_rx) = mpsc:: channel ( 0 ) ;
84
84
let ( trailers_tx, trailers_rx) = oneshot:: channel ( ) ;
85
85
@@ -94,7 +94,7 @@ impl Body {
94
94
data_tx,
95
95
trailers_tx : Some ( trailers_tx) ,
96
96
} ;
97
- let rx = Body :: new ( Kind :: Chan {
97
+ let rx = Recv :: new ( Kind :: Chan {
98
98
content_length,
99
99
want_tx,
100
100
data_rx,
@@ -104,18 +104,18 @@ impl Body {
104
104
( tx, rx)
105
105
}
106
106
107
- fn new ( kind : Kind ) -> Body {
108
- Body { kind }
107
+ fn new ( kind : Kind ) -> Recv {
108
+ Recv { kind }
109
109
}
110
110
111
111
#[ allow( dead_code) ]
112
- pub ( crate ) fn empty ( ) -> Body {
113
- Body :: new ( Kind :: Empty )
112
+ pub ( crate ) fn empty ( ) -> Recv {
113
+ Recv :: new ( Kind :: Empty )
114
114
}
115
115
116
116
#[ cfg( feature = "ffi" ) ]
117
- pub ( crate ) fn ffi ( ) -> Body {
118
- Body :: new ( Kind :: Ffi ( crate :: ffi:: UserBody :: new ( ) ) )
117
+ pub ( crate ) fn ffi ( ) -> Recv {
118
+ Recv :: new ( Kind :: Ffi ( crate :: ffi:: UserBody :: new ( ) ) )
119
119
}
120
120
121
121
#[ cfg( all( feature = "http2" , any( feature = "client" , feature = "server" ) ) ) ]
@@ -129,7 +129,7 @@ impl Body {
129
129
if !content_length. is_exact ( ) && recv. is_end_stream ( ) {
130
130
content_length = DecodedLength :: ZERO ;
131
131
}
132
- let body = Body :: new ( Kind :: H2 {
132
+ let body = Recv :: new ( Kind :: H2 {
133
133
ping,
134
134
content_length,
135
135
recv,
@@ -194,7 +194,7 @@ impl Body {
194
194
}
195
195
}
196
196
197
- impl HttpBody for Body {
197
+ impl HttpBody for Recv {
198
198
type Data = Bytes ;
199
199
type Error = crate :: Error ;
200
200
@@ -270,7 +270,7 @@ impl HttpBody for Body {
270
270
}
271
271
}
272
272
273
- impl fmt:: Debug for Body {
273
+ impl fmt:: Debug for Recv {
274
274
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
275
275
#[ derive( Debug ) ]
276
276
struct Streaming ;
@@ -382,14 +382,14 @@ mod tests {
382
382
use std:: mem;
383
383
use std:: task:: Poll ;
384
384
385
- use super :: { Body , DecodedLength , HttpBody , Sender , SizeHint } ;
385
+ use super :: { DecodedLength , HttpBody , Recv , Sender , SizeHint } ;
386
386
387
387
#[ test]
388
388
fn test_size_of ( ) {
389
389
// These are mostly to help catch *accidentally* increasing
390
390
// the size by too much.
391
391
392
- let body_size = mem:: size_of :: < Body > ( ) ;
392
+ let body_size = mem:: size_of :: < Recv > ( ) ;
393
393
let body_expected_size = mem:: size_of :: < u64 > ( ) * 6 ;
394
394
assert ! (
395
395
body_size <= body_expected_size,
@@ -398,7 +398,7 @@ mod tests {
398
398
body_expected_size,
399
399
) ;
400
400
401
- assert_eq ! ( body_size, mem:: size_of:: <Option <Body >>( ) , "Option<Body>" ) ;
401
+ assert_eq ! ( body_size, mem:: size_of:: <Option <Recv >>( ) , "Option<Body>" ) ;
402
402
403
403
assert_eq ! (
404
404
mem:: size_of:: <Sender >( ) ,
@@ -415,18 +415,18 @@ mod tests {
415
415
416
416
#[ test]
417
417
fn size_hint ( ) {
418
- fn eq ( body : Body , b : SizeHint , note : & str ) {
418
+ fn eq ( body : Recv , b : SizeHint , note : & str ) {
419
419
let a = body. size_hint ( ) ;
420
420
assert_eq ! ( a. lower( ) , b. lower( ) , "lower for {:?}" , note) ;
421
421
assert_eq ! ( a. upper( ) , b. upper( ) , "upper for {:?}" , note) ;
422
422
}
423
423
424
- eq ( Body :: empty ( ) , SizeHint :: with_exact ( 0 ) , "empty" ) ;
424
+ eq ( Recv :: empty ( ) , SizeHint :: with_exact ( 0 ) , "empty" ) ;
425
425
426
- eq ( Body :: channel ( ) . 1 , SizeHint :: new ( ) , "channel" ) ;
426
+ eq ( Recv :: channel ( ) . 1 , SizeHint :: new ( ) , "channel" ) ;
427
427
428
428
eq (
429
- Body :: new_channel ( DecodedLength :: new ( 4 ) , /*wanter =*/ false ) . 1 ,
429
+ Recv :: new_channel ( DecodedLength :: new ( 4 ) , /*wanter =*/ false ) . 1 ,
430
430
SizeHint :: with_exact ( 4 ) ,
431
431
"channel with length" ,
432
432
) ;
@@ -435,7 +435,7 @@ mod tests {
435
435
#[ cfg( not( miri) ) ]
436
436
#[ tokio:: test]
437
437
async fn channel_abort ( ) {
438
- let ( tx, mut rx) = Body :: channel ( ) ;
438
+ let ( tx, mut rx) = Recv :: channel ( ) ;
439
439
440
440
tx. abort ( ) ;
441
441
@@ -446,7 +446,7 @@ mod tests {
446
446
#[ cfg( not( miri) ) ]
447
447
#[ tokio:: test]
448
448
async fn channel_abort_when_buffer_is_full ( ) {
449
- let ( mut tx, mut rx) = Body :: channel ( ) ;
449
+ let ( mut tx, mut rx) = Recv :: channel ( ) ;
450
450
451
451
tx. try_send_data ( "chunk 1" . into ( ) ) . expect ( "send 1" ) ;
452
452
// buffer is full, but can still send abort
@@ -461,7 +461,7 @@ mod tests {
461
461
462
462
#[ test]
463
463
fn channel_buffers_one ( ) {
464
- let ( mut tx, _rx) = Body :: channel ( ) ;
464
+ let ( mut tx, _rx) = Recv :: channel ( ) ;
465
465
466
466
tx. try_send_data ( "chunk 1" . into ( ) ) . expect ( "send 1" ) ;
467
467
@@ -473,14 +473,14 @@ mod tests {
473
473
#[ cfg( not( miri) ) ]
474
474
#[ tokio:: test]
475
475
async fn channel_empty ( ) {
476
- let ( _, mut rx) = Body :: channel ( ) ;
476
+ let ( _, mut rx) = Recv :: channel ( ) ;
477
477
478
478
assert ! ( rx. data( ) . await . is_none( ) ) ;
479
479
}
480
480
481
481
#[ test]
482
482
fn channel_ready ( ) {
483
- let ( mut tx, _rx) = Body :: new_channel ( DecodedLength :: CHUNKED , /*wanter = */ false ) ;
483
+ let ( mut tx, _rx) = Recv :: new_channel ( DecodedLength :: CHUNKED , /*wanter = */ false ) ;
484
484
485
485
let mut tx_ready = tokio_test:: task:: spawn ( tx. ready ( ) ) ;
486
486
@@ -489,7 +489,7 @@ mod tests {
489
489
490
490
#[ test]
491
491
fn channel_wanter ( ) {
492
- let ( mut tx, mut rx) = Body :: new_channel ( DecodedLength :: CHUNKED , /*wanter = */ true ) ;
492
+ let ( mut tx, mut rx) = Recv :: new_channel ( DecodedLength :: CHUNKED , /*wanter = */ true ) ;
493
493
494
494
let mut tx_ready = tokio_test:: task:: spawn ( tx. ready ( ) ) ;
495
495
let mut rx_data = tokio_test:: task:: spawn ( rx. data ( ) ) ;
@@ -510,7 +510,7 @@ mod tests {
510
510
511
511
#[ test]
512
512
fn channel_notices_closure ( ) {
513
- let ( mut tx, rx) = Body :: new_channel ( DecodedLength :: CHUNKED , /*wanter = */ true ) ;
513
+ let ( mut tx, rx) = Recv :: new_channel ( DecodedLength :: CHUNKED , /*wanter = */ true ) ;
514
514
515
515
let mut tx_ready = tokio_test:: task:: spawn ( tx. ready ( ) ) ;
516
516
0 commit comments