1
- use futures_lite:: { io, prelude:: * , ready} ;
1
+ use futures_lite:: { io, prelude:: * , ready, AsyncRead as Read } ;
2
2
use serde:: { de:: DeserializeOwned , Serialize } ;
3
3
4
4
use std:: fmt:: { self , Debug } ;
@@ -12,7 +12,7 @@ pin_project_lite::pin_project! {
12
12
/// A streaming HTTP body.
13
13
///
14
14
/// `Body` represents the HTTP body of both `Request` and `Response`. It's completely
15
- /// streaming, and implements `AsyncBufRead ` to make reading from it both convenient and
15
+ /// streaming, and implements `AsyncRead ` to make reading from it both convenient and
16
16
/// performant.
17
17
///
18
18
/// Both `Request` and `Response` take `Body` by `Into<Body>`, which means that passing string
@@ -53,7 +53,7 @@ pin_project_lite::pin_project! {
53
53
/// and not rely on the fallback mechanisms. However, they're still there if you need them.
54
54
pub struct Body {
55
55
#[ pin]
56
- reader: Box <dyn AsyncBufRead + Unpin + Send + Sync + ' static >,
56
+ reader: Box <dyn Read + Unpin + Send + Sync + ' static >,
57
57
mime: Mime ,
58
58
length: Option <usize >,
59
59
bytes_read: usize
@@ -103,7 +103,7 @@ impl Body {
103
103
/// req.set_body(Body::from_reader(cursor, Some(len)));
104
104
/// ```
105
105
pub fn from_reader (
106
- reader : impl AsyncBufRead + Unpin + Send + Sync + ' static ,
106
+ reader : impl Read + Unpin + Send + Sync + ' static ,
107
107
len : Option < usize > ,
108
108
) -> Self {
109
109
Self {
@@ -127,7 +127,7 @@ impl Body {
127
127
/// let body = Body::from_reader(cursor, None);
128
128
/// let _ = body.into_reader();
129
129
/// ```
130
- pub fn into_reader ( self ) -> Box < dyn AsyncBufRead + Unpin + Send + Sync + ' static > {
130
+ pub fn into_reader ( self ) -> Box < dyn Read + Unpin + Send + Sync + ' static > {
131
131
self . reader
132
132
}
133
133
@@ -383,7 +383,7 @@ impl Body {
383
383
Ok ( Self {
384
384
mime,
385
385
length : Some ( len as usize ) ,
386
- reader : Box :: new ( io :: BufReader :: new ( file) ) ,
386
+ reader : Box :: new ( file) ,
387
387
bytes_read : 0 ,
388
388
} )
389
389
}
@@ -483,17 +483,6 @@ impl AsyncRead for Body {
483
483
}
484
484
}
485
485
486
- impl AsyncBufRead for Body {
487
- #[ allow( missing_doc_code_examples) ]
488
- fn poll_fill_buf ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < & ' _ [ u8 ] > > {
489
- self . project ( ) . reader . poll_fill_buf ( cx)
490
- }
491
-
492
- fn consume ( mut self : Pin < & mut Self > , amt : usize ) {
493
- Pin :: new ( & mut self . reader ) . consume ( amt)
494
- }
495
- }
496
-
497
486
/// Look at first few bytes of a file to determine the mime type.
498
487
/// This is used for various binary formats such as images and videos.
499
488
#[ cfg( all( feature = "fs" , not( target_os = "unknown" ) ) ) ]
0 commit comments