@@ -536,10 +536,16 @@ pub async fn serve_interface<T: {wrpc_transport}::Serve, U>(
536
536
let params = self . print_docs_and_params ( func, & sig) ;
537
537
match func. results . iter_types ( ) . collect :: < Vec < _ > > ( ) . as_slice ( ) {
538
538
[ ] => {
539
- uwrite ! ( self . src, " -> {anyhow}::Result<()>" , ) ;
539
+ uwrite ! (
540
+ self . src,
541
+ " -> impl ::core::future::Future<Output = {anyhow}::Result<()>> + Send + 'a"
542
+ ) ;
540
543
}
541
544
[ ty] => {
542
- uwrite ! ( self . src, " -> {anyhow}::Result<" , ) ;
545
+ uwrite ! (
546
+ self . src,
547
+ " -> impl ::core::future::Future<Output = {anyhow}::Result<"
548
+ ) ;
543
549
if async_params || !paths. is_empty ( ) {
544
550
self . push_str ( "(" ) ;
545
551
}
@@ -551,10 +557,13 @@ pub async fn serve_interface<T: {wrpc_transport}::Serve, U>(
551
557
wrpc_transport = self . gen . wrpc_transport_path( ) ,
552
558
) ;
553
559
}
554
- uwrite ! ( self . src, ">" ) ;
560
+ uwrite ! ( self . src, ">> + Send + 'a " ) ;
555
561
}
556
562
types => {
557
- uwrite ! ( self . src, " -> {anyhow}::Result<(" , ) ;
563
+ uwrite ! (
564
+ self . src,
565
+ " -> impl ::core::future::Future<Output = {anyhow}::Result<(" ,
566
+ ) ;
558
567
for ty in types {
559
568
self . print_ty ( ty, true , false ) ;
560
569
self . push_str ( ", " ) ;
@@ -566,17 +575,23 @@ pub async fn serve_interface<T: {wrpc_transport}::Serve, U>(
566
575
wrpc_transport = self . gen . wrpc_transport_path( ) ,
567
576
) ;
568
577
}
569
- uwrite ! ( self . src, ")>" ) ;
578
+ uwrite ! ( self . src, ")>> + Send + 'a " ) ;
570
579
}
571
580
} ;
572
- self . src . push_str ( "{\n " ) ;
581
+ self . push_str (
582
+ r"
583
+ {
584
+ async move {" ,
585
+ ) ;
573
586
574
587
if func. results . len ( ) == 0 || ( !async_params && paths. is_empty ( ) ) {
575
588
uwrite ! (
576
589
self . src,
577
- r#"let wrpc__ = {anyhow}::Context::context(
578
- wrpc__.invoke_values_blocking(cx__, "{instance}", "{}", ({params}), "# ,
590
+ r#"
591
+ let wrpc__ = {anyhow}::Context::context(
592
+ {wrpc_transport}::SendFuture::send(wrpc__.invoke_values_blocking(cx__, "{instance}", "{}", ({params}), "# ,
579
593
rpc_func_name( func) ,
594
+ wrpc_transport = self . gen . wrpc_transport_path( ) ,
580
595
params = {
581
596
let s = params. join( ", " ) ;
582
597
if params. len( ) == 1 {
@@ -595,11 +610,11 @@ pub async fn serve_interface<T: {wrpc_transport}::Serve, U>(
595
610
self . src . push_str ( ".as_slice(), " ) ;
596
611
}
597
612
}
598
- self . src . push_str ( "]).await,\n " ) ;
613
+ self . src . push_str ( "])) .await,\n " ) ;
599
614
uwriteln ! (
600
615
self . src,
601
616
r#"
602
- "failed to invoke `{instance}.{}`")?;"# ,
617
+ "failed to invoke `{instance}.{}`")?;"# ,
603
618
func. name,
604
619
) ;
605
620
if func. results . len ( ) == 1 {
@@ -609,9 +624,11 @@ pub async fn serve_interface<T: {wrpc_transport}::Serve, U>(
609
624
} else {
610
625
uwrite ! (
611
626
self . src,
612
- r#"let (wrpc__, io__) = {anyhow}::Context::context(
613
- wrpc__.invoke_values(cx__, "{instance}", "{}", ({params}), "# ,
627
+ r#"
628
+ let (wrpc__, io__) = {anyhow}::Context::context(
629
+ {wrpc_transport}::SendFuture::send(wrpc__.invoke_values(cx__, "{instance}", "{}", ({params}), "# ,
614
630
rpc_func_name( func) ,
631
+ wrpc_transport = self . gen . wrpc_transport_path( ) ,
615
632
params = {
616
633
let s = params. join( ", " ) ;
617
634
if params. len( ) == 1 {
@@ -630,11 +647,11 @@ pub async fn serve_interface<T: {wrpc_transport}::Serve, U>(
630
647
self . src . push_str ( ".as_slice(), " ) ;
631
648
}
632
649
}
633
- self . src . push_str ( "]).await,\n " ) ;
650
+ self . src . push_str ( "])) .await,\n " ) ;
634
651
uwriteln ! (
635
652
self . src,
636
653
r#"
637
- "failed to invoke `{instance}.{}`")?;"# ,
654
+ "failed to invoke `{instance}.{}`")?;"# ,
638
655
func. name,
639
656
) ;
640
657
if func. results . len ( ) == 1 {
@@ -653,7 +670,12 @@ pub async fn serve_interface<T: {wrpc_transport}::Serve, U>(
653
670
self . push_str ( "io__))\n " ) ;
654
671
}
655
672
}
656
- self . push_str ( "}\n " ) ;
673
+ uwriteln ! (
674
+ self . src,
675
+ r"
676
+ }}
677
+ }}"
678
+ ) ;
657
679
658
680
match func. kind {
659
681
FunctionKind :: Freestanding => { }
@@ -723,9 +745,6 @@ pub async fn serve_interface<T: {wrpc_transport}::Serve, U>(
723
745
if !sig. private {
724
746
self . push_str ( "pub " ) ;
725
747
}
726
- if self . in_import {
727
- self . push_str ( "async " ) ;
728
- }
729
748
self . push_str ( "fn " ) ;
730
749
if sig. use_item_name {
731
750
if let FunctionKind :: Constructor ( _) = & func. kind {
0 commit comments