@@ -49,18 +49,13 @@ impl<'a> MethodGen<'a> {
49
49
}
50
50
51
51
fn write_sync_client ( & self , w : & mut CodeWriter ) {
52
- let input = self . root_scope . find_message ( self . proto . get_input_type ( ) ) . rust_fq_name ( ) ;
53
- let output = self . root_scope . find_message ( self . proto . get_output_type ( ) ) . rust_fq_name ( ) ;
54
-
55
52
w. def_fn ( & self . sync_sig ( ) , |w| {
56
- w. write_line ( & format ! ( "::grpc::futuresx::wait2(self.async_client.{}(p))" , self . proto. get_name( ) ) ) ;
53
+ // https://github.com/alexcrichton/futures-rs/issues/97
54
+ w. write_line ( & format ! ( "::futures::Future::wait(self.async_client.{}(p))" , self . proto. get_name( ) ) ) ;
57
55
} ) ;
58
56
}
59
57
60
58
fn write_async_client ( & self , w : & mut CodeWriter ) {
61
- let input = self . root_scope . find_message ( self . proto . get_input_type ( ) ) . rust_fq_name ( ) ;
62
- let output = self . root_scope . find_message ( self . proto . get_output_type ( ) ) . rust_fq_name ( ) ;
63
-
64
59
w. def_fn ( & self . async_sig ( ) , |w| {
65
60
self . write_method_descriptor ( w,
66
61
& format ! ( "let method: ::grpc::method::MethodDescriptor<{}, {}> = " , self . input( ) , self . output( ) ) ,
@@ -210,15 +205,15 @@ impl<'a> ServiceGen<'a> {
210
205
} ) ;
211
206
}
212
207
213
- fn write_server ( & self , w : & mut CodeWriter ) {
208
+ fn write_sync_server ( & self , w : & mut CodeWriter ) {
214
209
w. pub_struct ( & self . sync_server_name ( ) , |w| {
215
210
w. field_decl ( "server" , "::grpc::server::GrpcServer" ) ;
216
211
} ) ;
217
212
218
213
w. write_line ( "" ) ;
219
214
220
215
w. impl_self_block ( & self . sync_server_name ( ) , |w| {
221
- w. pub_fn ( format ! ( "new<H : {} + 'static + Sync + Send>(h: H) -> {} " , self . sync_intf_name( ) , self . sync_server_name ( ) ) , |w| {
216
+ w. pub_fn ( format ! ( "new<H : {} + 'static + Sync + Send>(h: H) -> Self " , self . sync_intf_name( ) ) , |w| {
222
217
w. write_line ( "let handler_arc = ::std::sync::Arc::new(h);" ) ;
223
218
w. block ( "let service_definition = ::std::sync::Arc::new(::grpc::method::ServerServiceDefinition::new(" , "));" , |w| {
224
219
w. block ( "vec![" , "]," , |w| {
@@ -247,6 +242,20 @@ impl<'a> ServiceGen<'a> {
247
242
} ) ;
248
243
}
249
244
245
+ fn write_async_server ( & self , w : & mut CodeWriter ) {
246
+ w. pub_struct ( & self . async_server_name ( ) , |w| {
247
+ } ) ;
248
+
249
+ w. write_line ( "" ) ;
250
+
251
+ w. impl_self_block ( & self . async_server_name ( ) , |w| {
252
+ w. pub_fn ( format ! ( "new<H : {} + 'static + Sync + Send>(h: H) -> Self" , self . async_intf_name( ) ) , |w| {
253
+ w. expr_block ( self . async_server_name ( ) , |w| {
254
+ } ) ;
255
+ } ) ;
256
+ } ) ;
257
+ }
258
+
250
259
fn write ( & self , w : & mut CodeWriter ) {
251
260
w. comment ( "interface" ) ;
252
261
w. write_line ( "" ) ;
@@ -264,7 +273,9 @@ impl<'a> ServiceGen<'a> {
264
273
w. write_line ( "" ) ;
265
274
w. comment ( "sync server" ) ;
266
275
w. write_line ( "" ) ;
267
- self . write_server ( w) ;
276
+ self . write_sync_server ( w) ;
277
+ w. write_line ( "" ) ;
278
+ self . write_async_server ( w) ;
268
279
}
269
280
}
270
281
0 commit comments