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
+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>;
}
}
};