@@ -623,16 +623,21 @@ where
623623 S : quic:: RecvStream ,
624624{
625625 /// Receive some of the request body.
626- pub async fn recv_data ( & mut self ) -> Result < Option < impl Buf > , Error > {
626+ pub fn poll_recv_data (
627+ & mut self ,
628+ cx : & mut Context < ' _ > ,
629+ ) -> Poll < Result < Option < impl Buf > , Error > > {
627630 if !self . stream . has_data ( ) {
628- let frame = future:: poll_fn ( |cx| self . stream . poll_next ( cx) )
629- . await
631+ let frame = self
632+ . stream
633+ . poll_next ( cx)
630634 . map_err ( |e| self . maybe_conn_err ( e) ) ?;
631- match frame {
635+
636+ match ready ! ( frame) {
632637 Some ( Frame :: Data { .. } ) => ( ) ,
633638 Some ( Frame :: Headers ( encoded) ) => {
634639 self . trailers = Some ( encoded) ;
635- return Ok ( None ) ;
640+ return Poll :: Ready ( Ok ( None ) ) ;
636641 }
637642
638643 //= https://www.rfc-editor.org/rfc/rfc9114#section-4.1
@@ -657,15 +662,18 @@ where
657662 //# The MAX_PUSH_ID frame is always sent on the control stream. Receipt
658663 //# of a MAX_PUSH_ID frame on any other stream MUST be treated as a
659664 //# connection error of type H3_FRAME_UNEXPECTED.
660- Some ( _) => return Err ( Code :: H3_FRAME_UNEXPECTED . into ( ) ) ,
661- None => return Ok ( None ) ,
665+ Some ( _) => return Poll :: Ready ( Err ( Code :: H3_FRAME_UNEXPECTED . into ( ) ) ) ,
666+ None => return Poll :: Ready ( Ok ( None ) ) ,
662667 }
663668 }
664669
665- let data = future:: poll_fn ( |cx| self . stream . poll_data ( cx) )
666- . await
667- . map_err ( |e| self . maybe_conn_err ( e) ) ?;
668- Ok ( data)
670+ self . stream
671+ . poll_data ( cx)
672+ . map_err ( |e| self . maybe_conn_err ( e) )
673+ }
674+ /// Receive some of the request body.
675+ pub async fn recv_data ( & mut self ) -> Result < Option < impl Buf > , Error > {
676+ future:: poll_fn ( |cx| self . poll_recv_data ( cx) ) . await
669677 }
670678
671679 /// Receive trailers
0 commit comments