File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -105,13 +105,17 @@ where
105105 R : AsyncRead + Unpin ,
106106 W : AsyncWrite + Unpin ,
107107{
108- pub async fn write_message ( & mut self , msg : JsonRpcMessage ) -> Result < ( ) , std:: io:: Error > {
108+ pub async fn write_message (
109+ self : & mut Pin < & mut Self > ,
110+ msg : JsonRpcMessage ,
111+ ) -> Result < ( ) , std:: io:: Error > {
109112 let json = serde_json:: to_string ( & msg) ?;
110- Pin :: new ( & mut self . writer )
111- . write_all ( json. as_bytes ( ) )
112- . await ?;
113- Pin :: new ( & mut self . writer ) . write_all ( b"\n " ) . await ?;
114- Pin :: new ( & mut self . writer ) . flush ( ) . await ?;
113+
114+ let mut this = self . as_mut ( ) . project ( ) ;
115+ this. writer . write_all ( json. as_bytes ( ) ) . await ?;
116+ this. writer . write_all ( b"\n " ) . await ?;
117+ this. writer . flush ( ) . await ?;
118+
115119 Ok ( ( ) )
116120 }
117121}
@@ -139,6 +143,7 @@ where
139143 {
140144 use futures:: StreamExt ;
141145 let mut service = self . service ;
146+ let mut transport = Pin :: new ( & mut transport) ;
142147
143148 tracing:: info!( "Server started" ) ;
144149 while let Some ( msg_result) = transport. next ( ) . await {
You can’t perform that action at this time.
0 commit comments