@@ -8,6 +8,7 @@ use crate::http::response::try_from_incoming;
88use crate :: io:: { self , AsyncOutputStream , AsyncPollable } ;
99use crate :: runtime:: WaitFor ;
1010use crate :: time:: Duration ;
11+ use pin_project_lite:: pin_project;
1112use std:: future:: Future ;
1213use std:: pin:: Pin ;
1314use std:: task:: { Context , Poll } ;
@@ -83,24 +84,35 @@ impl Client {
8384
8485 let outgoing_body = OutgoingBody :: new ( AsyncOutputStream :: new ( wasi_stream) , wasi_body) ;
8586
86- struct IncomingResponseFuture {
87- subscription : WaitFor ,
88- wasi : WasiFutureIncomingResponse ,
87+ pin_project ! {
88+ struct IncomingResponseFuture {
89+ #[ pin]
90+ subscription: Option <WaitFor >,
91+ wasi: WasiFutureIncomingResponse ,
92+ }
8993 }
9094 impl Future for IncomingResponseFuture {
9195 type Output = Result < Response < IncomingBody > > ;
9296
9397 fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
94- match pin_project ( self . subscription ) . poll ( cx) {
98+ let this = self . project ( ) ;
99+ match this. subscription . as_pin_mut ( ) . expect ( "make it so" ) . poll ( cx) {
95100 Poll :: Pending => Poll :: Pending ,
96- Poll :: Ready ( response) => Poll :: Ready ( try_from_incoming ( response) ) ,
101+ Poll :: Ready ( ( ) ) => Poll :: Ready (
102+ this. wasi
103+ . get ( )
104+ . unwrap ( )
105+ . unwrap ( )
106+ . map_err ( Error :: from)
107+ . and_then ( try_from_incoming) ,
108+ ) ,
97109 }
98110 }
99111 }
100112
101113 let subscription = AsyncPollable :: new ( res. subscribe ( ) ) . wait_for ( ) ;
102114 let future = IncomingResponseFuture {
103- subscription,
115+ subscription : Some ( subscription ) ,
104116 wasi : res,
105117 } ;
106118
0 commit comments