Skip to content

Commit 05c6cee

Browse files
committed
Add trait variant
1 parent 160b561 commit 05c6cee

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

tarpc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ tracing = { version = "0.1", default-features = false, features = [
5959
"log",
6060
] }
6161
tracing-opentelemetry = { version = "0.22.0", default-features = false }
62+
trait-variant = "0.1.1"
6263
opentelemetry = { version = "0.21.0", default-features = false }
6364

6465

tarpc/src/client/stub.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ mod mock;
1616
/// A connection to a remote service.
1717
/// Calls the service with requests of type `Req` and receives responses of type `Resp`.
1818
#[allow(async_fn_in_trait)]
19+
#[trait_variant::make(TokioStub: Send)]
1920
pub trait Stub {
2021
/// The service request type.
2122
type Req: RequestName;
@@ -40,13 +41,13 @@ where
4041
}
4142
}
4243

43-
impl<S> Stub for S
44-
where
45-
S: Serve + Clone,
46-
{
47-
type Req = S::Req;
48-
type Resp = S::Resp;
49-
async fn call(&self, ctx: context::Context, req: Self::Req) -> Result<Self::Resp, RpcError> {
50-
self.clone().serve(ctx, req).await.map_err(RpcError::Server)
51-
}
52-
}
44+
// impl<S> Stub for S
45+
// where
46+
// S: Serve + Clone,
47+
// {
48+
// type Req = S::Req;
49+
// type Resp = S::Resp;
50+
// async fn call(&self, ctx: context::Context, req: Self::Req) -> Result<Self::Resp, RpcError> {
51+
// self.clone().serve(ctx, req).await.map_err(RpcError::Server)
52+
// }
53+
// }

0 commit comments

Comments
 (0)