tonic-build: use unified syntax to clone Arcs (#1182)

This commit is contained in:
Jan Teske
2022-12-13 13:22:54 -05:00
committed by GitHub
parent 35c4946d35
commit 25ea473abd
4 changed files with 11 additions and 11 deletions
+5 -5
View File
@@ -179,7 +179,7 @@ pub(crate) fn generate_internal<T: Service>(
impl<T: #server_trait> Clone for _Inner<T> { impl<T: #server_trait> Clone for _Inner<T> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self(self.0.clone()) Self(Arc::clone(&self.0))
} }
} }
@@ -404,7 +404,7 @@ fn generate_unary<T: Method>(
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>; type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
fn call(&mut self, request: tonic::Request<#request>) -> Self::Future { fn call(&mut self, request: tonic::Request<#request>) -> Self::Future {
let inner = self.0.clone(); let inner = Arc::clone(&self.0);
let fut = async move { let fut = async move {
(*inner).#method_ident(request).await (*inner).#method_ident(request).await
}; };
@@ -456,7 +456,7 @@ fn generate_server_streaming<T: Method>(
type Future = BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>; type Future = BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>;
fn call(&mut self, request: tonic::Request<#request>) -> Self::Future { fn call(&mut self, request: tonic::Request<#request>) -> Self::Future {
let inner = self.0.clone(); let inner = Arc::clone(&self.0);
let fut = async move { let fut = async move {
(*inner).#method_ident(request).await (*inner).#method_ident(request).await
}; };
@@ -505,7 +505,7 @@ fn generate_client_streaming<T: Method>(
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>; type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
fn call(&mut self, request: tonic::Request<tonic::Streaming<#request>>) -> Self::Future { fn call(&mut self, request: tonic::Request<tonic::Streaming<#request>>) -> Self::Future {
let inner = self.0.clone(); let inner = Arc::clone(&self.0);
let fut = async move { let fut = async move {
(*inner).#method_ident(request).await (*inner).#method_ident(request).await
@@ -559,7 +559,7 @@ fn generate_streaming<T: Method>(
type Future = BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>; type Future = BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>;
fn call(&mut self, request: tonic::Request<tonic::Streaming<#request>>) -> Self::Future { fn call(&mut self, request: tonic::Request<tonic::Streaming<#request>>) -> Self::Future {
let inner = self.0.clone(); let inner = Arc::clone(&self.0);
let fut = async move { let fut = async move {
(*inner).#method_ident(request).await (*inner).#method_ident(request).await
}; };
+3 -3
View File
@@ -278,7 +278,7 @@ pub mod health_server {
&mut self, &mut self,
request: tonic::Request<super::HealthCheckRequest>, request: tonic::Request<super::HealthCheckRequest>,
) -> Self::Future { ) -> Self::Future {
let inner = self.0.clone(); let inner = Arc::clone(&self.0);
let fut = async move { (*inner).check(request).await }; let fut = async move { (*inner).check(request).await };
Box::pin(fut) Box::pin(fut)
} }
@@ -317,7 +317,7 @@ pub mod health_server {
&mut self, &mut self,
request: tonic::Request<super::HealthCheckRequest>, request: tonic::Request<super::HealthCheckRequest>,
) -> Self::Future { ) -> Self::Future {
let inner = self.0.clone(); let inner = Arc::clone(&self.0);
let fut = async move { (*inner).watch(request).await }; let fut = async move { (*inner).watch(request).await };
Box::pin(fut) Box::pin(fut)
} }
@@ -366,7 +366,7 @@ pub mod health_server {
} }
impl<T: Health> Clone for _Inner<T> { impl<T: Health> Clone for _Inner<T> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self(self.0.clone()) Self(Arc::clone(&self.0))
} }
} }
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> { impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
@@ -337,7 +337,7 @@ pub mod server_reflection_server {
tonic::Streaming<super::ServerReflectionRequest>, tonic::Streaming<super::ServerReflectionRequest>,
>, >,
) -> Self::Future { ) -> Self::Future {
let inner = self.0.clone(); let inner = Arc::clone(&self.0);
let fut = async move { let fut = async move {
(*inner).server_reflection_info(request).await (*inner).server_reflection_info(request).await
}; };
@@ -388,7 +388,7 @@ pub mod server_reflection_server {
} }
impl<T: ServerReflection> Clone for _Inner<T> { impl<T: ServerReflection> Clone for _Inner<T> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self(self.0.clone()) Self(Arc::clone(&self.0))
} }
} }
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> { impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
@@ -139,7 +139,7 @@ pub mod server {
&mut self, &mut self,
request: tonic::Request<super::HelloRequest>, request: tonic::Request<super::HelloRequest>,
) -> Self::Future { ) -> Self::Future {
let inner = self.0.clone(); let inner = Arc::clone(&self.0);
let fut = async move { inner.say_hello(request).await }; let fut = async move { inner.say_hello(request).await };
Box::pin(fut) Box::pin(fut)
} }