@@ -623,16 +623,21 @@ where
623
623
S : quic:: RecvStream ,
624
624
{
625
625
/// 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 > > {
627
630
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)
630
634
. map_err ( |e| self . maybe_conn_err ( e) ) ?;
631
- match frame {
635
+
636
+ match ready ! ( frame) {
632
637
Some ( Frame :: Data { .. } ) => ( ) ,
633
638
Some ( Frame :: Headers ( encoded) ) => {
634
639
self . trailers = Some ( encoded) ;
635
- return Ok ( None ) ;
640
+ return Poll :: Ready ( Ok ( None ) ) ;
636
641
}
637
642
638
643
//= https://www.rfc-editor.org/rfc/rfc9114#section-4.1
@@ -657,15 +662,18 @@ where
657
662
//# The MAX_PUSH_ID frame is always sent on the control stream. Receipt
658
663
//# of a MAX_PUSH_ID frame on any other stream MUST be treated as a
659
664
//# 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 ) ) ,
662
667
}
663
668
}
664
669
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
669
677
}
670
678
671
679
/// Receive trailers
0 commit comments