@@ -99,12 +99,14 @@ fn generate_unary(method: &Method, proto: &str, path: String) -> TokenStream {
9999 let ( request, response) = crate :: replace_wellknown ( proto, & method) ;
100100
101101 quote ! {
102- pub async fn #ident( & mut self , request: tonic:: Request <#request>)
103- -> Result <tonic:: Response <#response>, tonic:: Status > {
102+ pub async fn #ident(
103+ & mut self ,
104+ request: impl tonic:: IntoRequest <#request>,
105+ ) -> Result <tonic:: Response <#response>, tonic:: Status > {
104106 self . ready( ) . await ?;
105107 let codec = tonic:: codec:: ProstCodec :: new( ) ;
106108 let path = http:: uri:: PathAndQuery :: from_static( #path) ;
107- self . inner. unary( request, path, codec) . await
109+ self . inner. unary( request. into_request ( ) , path, codec) . await
108110 }
109111 }
110112}
@@ -115,12 +117,14 @@ fn generate_server_streaming(method: &Method, proto: &str, path: String) -> Toke
115117 let ( request, response) = crate :: replace_wellknown ( proto, & method) ;
116118
117119 quote ! {
118- pub async fn #ident( & mut self , request: tonic:: Request <#request>)
119- -> Result <tonic:: Response <tonic:: codec:: Streaming <#response>>, tonic:: Status > {
120+ pub async fn #ident(
121+ & mut self ,
122+ request: impl tonic:: IntoRequest <#request>,
123+ ) -> Result <tonic:: Response <tonic:: codec:: Streaming <#response>>, tonic:: Status > {
120124 self . ready( ) . await ?;
121125 let codec = tonic:: codec:: ProstCodec :: new( ) ;
122126 let path = http:: uri:: PathAndQuery :: from_static( #path) ;
123- self . inner. server_streaming( request, path, codec) . await
127+ self . inner. server_streaming( request. into_request ( ) , path, codec) . await
124128 }
125129 }
126130}
@@ -131,14 +135,14 @@ fn generate_client_streaming(method: &Method, proto: &str, path: String) -> Toke
131135 let ( request, response) = crate :: replace_wellknown ( proto, & method) ;
132136
133137 quote ! {
134- pub async fn #ident< S > ( & mut self , request : tonic :: Request < S > )
135- -> Result <tonic :: Response <#response> , tonic :: Status >
136- where S : Stream < Item = #request> + Send + ' static ,
137- {
138+ pub async fn #ident(
139+ & mut self ,
140+ request : impl tonic :: IntoStreamingRequest < Message = #request>
141+ ) -> Result <tonic :: Response <#response> , tonic :: Status > {
138142 self . ready( ) . await ?;
139143 let codec = tonic:: codec:: ProstCodec :: new( ) ;
140144 let path = http:: uri:: PathAndQuery :: from_static( #path) ;
141- self . inner. client_streaming( request, path, codec) . await
145+ self . inner. client_streaming( request. into_streaming_request ( ) , path, codec) . await
142146 }
143147 }
144148}
@@ -149,14 +153,14 @@ fn generate_streaming(method: &Method, proto: &str, path: String) -> TokenStream
149153 let ( request, response) = crate :: replace_wellknown ( proto, & method) ;
150154
151155 quote ! {
152- pub async fn #ident< S > ( & mut self , request : tonic :: Request < S > )
153- -> Result <tonic :: Response <tonic :: codec :: Streaming <#response>> , tonic :: Status >
154- where S : Stream < Item = #request> + Send + ' static ,
155- {
156+ pub async fn #ident(
157+ & mut self ,
158+ request : impl tonic :: IntoStreamingRequest < Message = #request>
159+ ) -> Result <tonic :: Response <tonic :: codec :: Streaming <#response>> , tonic :: Status > {
156160 self . ready( ) . await ?;
157161 let codec = tonic:: codec:: ProstCodec :: new( ) ;
158162 let path = http:: uri:: PathAndQuery :: from_static( #path) ;
159- self . inner. streaming( request, path, codec) . await
163+ self . inner. streaming( request. into_streaming_request ( ) , path, codec) . await
160164 }
161165 }
162166}
0 commit comments