fix(build): Allow Services to be named Result (#1203)

closes #1156
This commit is contained in:
Shrutesh Pachineela
2022-12-21 12:07:07 -05:00
committed by GitHub
parent a72cf04b44
commit a562a3ce32
10 changed files with 86 additions and 21 deletions
+4 -4
View File
@@ -225,7 +225,7 @@ fn generate_unary<T: Method>(
pub async fn #ident(
&mut self,
request: impl tonic::IntoRequest<#request>,
) -> Result<tonic::Response<#response>, tonic::Status> {
) -> std::result::Result<tonic::Response<#response>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
})?;
@@ -251,7 +251,7 @@ fn generate_server_streaming<T: Method>(
pub async fn #ident(
&mut self,
request: impl tonic::IntoRequest<#request>,
) -> Result<tonic::Response<tonic::codec::Streaming<#response>>, tonic::Status> {
) -> std::result::Result<tonic::Response<tonic::codec::Streaming<#response>>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
})?;
@@ -277,7 +277,7 @@ fn generate_client_streaming<T: Method>(
pub async fn #ident(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = #request>
) -> Result<tonic::Response<#response>, tonic::Status> {
) -> std::result::Result<tonic::Response<#response>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
})?;
@@ -303,7 +303,7 @@ fn generate_streaming<T: Method>(
pub async fn #ident(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = #request>
) -> Result<tonic::Response<tonic::codec::Streaming<#response>>, tonic::Status> {
) -> std::result::Result<tonic::Response<tonic::codec::Streaming<#response>>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
})?;
+7 -7
View File
@@ -144,7 +144,7 @@ pub(crate) fn generate_internal<T: Service>(
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
@@ -251,14 +251,14 @@ fn generate_trait_methods<T: Service>(
quote! {
#method_doc
async fn #name(&self, request: tonic::Request<#req_message>)
-> Result<tonic::Response<#res_message>, tonic::Status>;
-> std::result::Result<tonic::Response<#res_message>, tonic::Status>;
}
}
(true, false) => {
quote! {
#method_doc
async fn #name(&self, request: tonic::Request<tonic::Streaming<#req_message>>)
-> Result<tonic::Response<#res_message>, tonic::Status>;
-> std::result::Result<tonic::Response<#res_message>, tonic::Status>;
}
}
(false, true) => {
@@ -270,11 +270,11 @@ fn generate_trait_methods<T: Service>(
quote! {
#stream_doc
type #stream: futures_core::Stream<Item = Result<#res_message, tonic::Status>> + Send + 'static;
type #stream: futures_core::Stream<Item = std::result::Result<#res_message, tonic::Status>> + Send + 'static;
#method_doc
async fn #name(&self, request: tonic::Request<#req_message>)
-> Result<tonic::Response<Self::#stream>, tonic::Status>;
-> std::result::Result<tonic::Response<Self::#stream>, tonic::Status>;
}
}
(true, true) => {
@@ -286,11 +286,11 @@ fn generate_trait_methods<T: Service>(
quote! {
#stream_doc
type #stream: futures_core::Stream<Item = Result<#res_message, tonic::Status>> + Send + 'static;
type #stream: futures_core::Stream<Item = std::result::Result<#res_message, tonic::Status>> + Send + 'static;
#method_doc
async fn #name(&self, request: tonic::Request<tonic::Streaming<#req_message>>)
-> Result<tonic::Response<Self::#stream>, tonic::Status>;
-> std::result::Result<tonic::Response<Self::#stream>, tonic::Status>;
}
}
};