Use fully qualified path for futures_core::Stream in codegen (#591)

This commit is contained in:
Ben Sully
2021-03-28 18:31:20 +01:00
committed by GitHub
parent 2788628916
commit 6c898a239f
7 changed files with 40 additions and 4 deletions
+2 -1
View File
@@ -18,6 +18,7 @@ members = [
"tests/extern_path/uuid",
"tests/ambiguous_methods",
"tests/extern_path/my_application",
"tests/integration_tests"
"tests/integration_tests",
"tests/stream_conflict",
]
+15
View File
@@ -0,0 +1,15 @@
[package]
name = "stream_conflict"
version = "0.1.0"
authors = ["Ben Sully <ben@bsull.io>"]
publish = false
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tonic = { path = "../../tonic" }
prost = "0.7"
[build-dependencies]
tonic-build = { path = "../../tonic-build" }
+3
View File
@@ -0,0 +1,3 @@
fn main() {
tonic_build::compile_protos("proto/stream_conflict.proto").unwrap();
}
@@ -0,0 +1,10 @@
syntax = "proto3";
package StreamConflict;
message Message {
bool ok = 1;
}
service Stream {
rpc RunStream(Message) returns (stream Message);
}
+7
View File
@@ -0,0 +1,7 @@
mod stream_conflict {
tonic::include_proto!("stream_conflict");
}
fn main() {
println!("Hello, world!");
}
+2 -2
View File
@@ -182,7 +182,7 @@ fn generate_trait_methods<T: Service>(
quote! {
#stream_doc
type #stream: Stream<Item = Result<#res_message, tonic::Status>> + Send + Sync + 'static;
type #stream: futures_core::Stream<Item = Result<#res_message, tonic::Status>> + Send + Sync + 'static;
#method_doc
async fn #name(&self, request: tonic::Request<#req_message>)
@@ -198,7 +198,7 @@ fn generate_trait_methods<T: Service>(
quote! {
#stream_doc
type #stream: Stream<Item = Result<#res_message, tonic::Status>> + Send + Sync + 'static;
type #stream: futures_core::Stream<Item = Result<#res_message, tonic::Status>> + Send + Sync + 'static;
#method_doc
async fn #name(&self, request: tonic::Request<tonic::Streaming<#req_message>>)
+1 -1
View File
@@ -1,7 +1,7 @@
//! Codegen exports used by `tonic-build`.
pub use async_trait::async_trait;
pub use futures_core::Stream;
pub use futures_core;
pub use futures_util::future::{ok, poll_fn, Ready};
pub use http_body::Body as HttpBody;