1- use futures_lite:: { io, prelude:: * , ready} ;
1+ use futures_lite:: { io, prelude:: * , ready, AsyncRead as Read } ;
22use serde:: { de:: DeserializeOwned , Serialize } ;
33
44use std:: fmt:: { self , Debug } ;
@@ -12,7 +12,7 @@ pin_project_lite::pin_project! {
1212 /// A streaming HTTP body.
1313 ///
1414 /// `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
1616 /// performant.
1717 ///
1818 /// Both `Request` and `Response` take `Body` by `Into<Body>`, which means that passing string
@@ -53,7 +53,7 @@ pin_project_lite::pin_project! {
5353 /// and not rely on the fallback mechanisms. However, they're still there if you need them.
5454 pub struct Body {
5555 #[ pin]
56- reader: Box <dyn AsyncBufRead + Unpin + Send + Sync + ' static >,
56+ reader: Box <dyn Read + Unpin + Send + Sync + ' static >,
5757 mime: Mime ,
5858 length: Option <usize >,
5959 bytes_read: usize
@@ -103,7 +103,7 @@ impl Body {
103103 /// req.set_body(Body::from_reader(cursor, Some(len)));
104104 /// ```
105105 pub fn from_reader (
106- reader : impl AsyncBufRead + Unpin + Send + Sync + ' static ,
106+ reader : impl Read + Unpin + Send + Sync + ' static ,
107107 len : Option < usize > ,
108108 ) -> Self {
109109 Self {
@@ -127,7 +127,7 @@ impl Body {
127127 /// let body = Body::from_reader(cursor, None);
128128 /// let _ = body.into_reader();
129129 /// ```
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 > {
131131 self . reader
132132 }
133133
@@ -383,7 +383,7 @@ impl Body {
383383 Ok ( Self {
384384 mime,
385385 length : Some ( len as usize ) ,
386- reader : Box :: new ( io :: BufReader :: new ( file) ) ,
386+ reader : Box :: new ( file) ,
387387 bytes_read : 0 ,
388388 } )
389389 }
@@ -483,17 +483,6 @@ impl AsyncRead for Body {
483483 }
484484}
485485
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-
497486/// Look at first few bytes of a file to determine the mime type.
498487/// This is used for various binary formats such as images and videos.
499488#[ cfg( all( feature = "fs" , not( target_os = "unknown" ) ) ) ]
0 commit comments