committed by
GitHub
parent
a72cf04b44
commit
a562a3ce32
@@ -22,4 +22,5 @@ members = [
|
||||
"tests/root-crate-path",
|
||||
"tests/compression",
|
||||
"tonic-web/tests/integration",
|
||||
"tests/service_named_result",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "service_named_result"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
prost = "0.11"
|
||||
tonic = {path = "../../tonic"}
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = {path = "../../tonic-build"}
|
||||
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2020 Lucio Franco
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tonic_build::compile_protos("proto/result.proto").unwrap();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
|
||||
package result;
|
||||
|
||||
service Result {
|
||||
rpc Listen(google.protobuf.Empty) returns (Reply) {}
|
||||
}
|
||||
|
||||
message Reply {
|
||||
int32 step = 1;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod pb {
|
||||
tonic::include_proto!("result");
|
||||
}
|
||||
@@ -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()))
|
||||
})?;
|
||||
|
||||
@@ -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>;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,7 +119,10 @@ pub mod health_client {
|
||||
pub async fn check(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::HealthCheckRequest>,
|
||||
) -> Result<tonic::Response<super::HealthCheckResponse>, tonic::Status> {
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::HealthCheckResponse>,
|
||||
tonic::Status,
|
||||
> {
|
||||
self.inner
|
||||
.ready()
|
||||
.await
|
||||
@@ -153,7 +156,7 @@ pub mod health_client {
|
||||
pub async fn watch(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::HealthCheckRequest>,
|
||||
) -> Result<
|
||||
) -> std::result::Result<
|
||||
tonic::Response<tonic::codec::Streaming<super::HealthCheckResponse>>,
|
||||
tonic::Status,
|
||||
> {
|
||||
@@ -186,10 +189,13 @@ pub mod health_server {
|
||||
async fn check(
|
||||
&self,
|
||||
request: tonic::Request<super::HealthCheckRequest>,
|
||||
) -> Result<tonic::Response<super::HealthCheckResponse>, tonic::Status>;
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::HealthCheckResponse>,
|
||||
tonic::Status,
|
||||
>;
|
||||
/// Server streaming response type for the Watch method.
|
||||
type WatchStream: futures_core::Stream<
|
||||
Item = Result<super::HealthCheckResponse, tonic::Status>,
|
||||
Item = std::result::Result<super::HealthCheckResponse, tonic::Status>,
|
||||
>
|
||||
+ Send
|
||||
+ 'static;
|
||||
@@ -211,7 +217,7 @@ pub mod health_server {
|
||||
async fn watch(
|
||||
&self,
|
||||
request: tonic::Request<super::HealthCheckRequest>,
|
||||
) -> Result<tonic::Response<Self::WatchStream>, tonic::Status>;
|
||||
) -> std::result::Result<tonic::Response<Self::WatchStream>, tonic::Status>;
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct HealthServer<T: Health> {
|
||||
@@ -266,7 +272,7 @@ pub mod health_server {
|
||||
fn poll_ready(
|
||||
&mut self,
|
||||
_cx: &mut Context<'_>,
|
||||
) -> Poll<Result<(), Self::Error>> {
|
||||
) -> Poll<std::result::Result<(), Self::Error>> {
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
fn call(&mut self, req: http::Request<B>) -> Self::Future {
|
||||
|
||||
@@ -218,7 +218,7 @@ pub mod server_reflection_client {
|
||||
request: impl tonic::IntoStreamingRequest<
|
||||
Message = super::ServerReflectionRequest,
|
||||
>,
|
||||
) -> Result<
|
||||
) -> std::result::Result<
|
||||
tonic::Response<tonic::codec::Streaming<super::ServerReflectionResponse>>,
|
||||
tonic::Status,
|
||||
> {
|
||||
@@ -248,7 +248,10 @@ pub mod server_reflection_server {
|
||||
pub trait ServerReflection: Send + Sync + 'static {
|
||||
/// Server streaming response type for the ServerReflectionInfo method.
|
||||
type ServerReflectionInfoStream: futures_core::Stream<
|
||||
Item = Result<super::ServerReflectionResponse, tonic::Status>,
|
||||
Item = std::result::Result<
|
||||
super::ServerReflectionResponse,
|
||||
tonic::Status,
|
||||
>,
|
||||
>
|
||||
+ Send
|
||||
+ 'static;
|
||||
@@ -257,7 +260,10 @@ pub mod server_reflection_server {
|
||||
async fn server_reflection_info(
|
||||
&self,
|
||||
request: tonic::Request<tonic::Streaming<super::ServerReflectionRequest>>,
|
||||
) -> Result<tonic::Response<Self::ServerReflectionInfoStream>, tonic::Status>;
|
||||
) -> std::result::Result<
|
||||
tonic::Response<Self::ServerReflectionInfoStream>,
|
||||
tonic::Status,
|
||||
>;
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct ServerReflectionServer<T: ServerReflection> {
|
||||
@@ -312,7 +318,7 @@ pub mod server_reflection_server {
|
||||
fn poll_ready(
|
||||
&mut self,
|
||||
_cx: &mut Context<'_>,
|
||||
) -> Poll<Result<(), Self::Error>> {
|
||||
) -> Poll<std::result::Result<(), Self::Error>> {
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
fn call(&mut self, req: http::Request<B>) -> Self::Future {
|
||||
|
||||
Reference in New Issue
Block a user