diff --git a/tonic-build/src/client.rs b/tonic-build/src/client.rs index 3056a9585..a5dec9d1f 100644 --- a/tonic-build/src/client.rs +++ b/tonic-build/src/client.rs @@ -133,7 +133,7 @@ fn generate_client_streaming(method: &Method, proto: &str, path: String) -> Toke quote! { pub async fn #ident(&mut self, request: tonic::Request) -> Result, tonic::Status> - where S: Stream> + Send + 'static, + where S: Stream + Send + 'static, { self.ready().await?; let codec = tonic::codec::ProstCodec::new(); @@ -151,7 +151,7 @@ fn generate_streaming(method: &Method, proto: &str, path: String) -> TokenStream quote! { pub async fn #ident(&mut self, request: tonic::Request) -> Result>, tonic::Status> - where S: Stream> + Send + 'static, + where S: Stream + Send + 'static, { self.ready().await?; let codec = tonic::codec::ProstCodec::new(); diff --git a/tonic-examples/src/routeguide/client.rs b/tonic-examples/src/routeguide/client.rs index f5ebd34fe..942c39fb1 100644 --- a/tonic-examples/src/routeguide/client.rs +++ b/tonic-examples/src/routeguide/client.rs @@ -25,7 +25,7 @@ async fn main() -> Result<(), Box> { println!("FEATURE = {:?}", response); - let outbound = async_stream::try_stream! { + let outbound = async_stream::stream! { let mut interval = Interval::new_interval(Duration::from_secs(1)); while let Some(time) = interval.next().await { diff --git a/tonic-interop/src/client.rs b/tonic-interop/src/client.rs index a463b030e..5aefdf1bf 100644 --- a/tonic-interop/src/client.rs +++ b/tonic-interop/src/client.rs @@ -79,13 +79,10 @@ pub async fn large_unary(client: &mut TestClient, assertions: &mut Vec) { - let requests = REQUEST_LENGTHS - .iter() - .map(|len| StreamingInputCallRequest { - payload: Some(crate::client_payload(*len as usize)), - ..Default::default() - }) - .map(|v| Ok(v)); + let requests = REQUEST_LENGTHS.iter().map(|len| StreamingInputCallRequest { + payload: Some(crate::client_payload(*len as usize)), + ..Default::default() + }); let stream = stream::iter(requests); @@ -154,9 +151,7 @@ pub async fn ping_pong(client: &mut TestClient, assertions: &mut Vec { let stream = response.into_inner(); @@ -359,7 +354,7 @@ pub async fn custom_metadata(client: &mut TestClient, assertions: &mut Vec Grpc { M1: Send + 'static, M2: Send + 'static, { - let request = request.map(|m| stream::once(future::ok(m))); + let request = request.map(|m| stream::once(future::ready(m))); self.client_streaming(request, path, codec).await } @@ -81,7 +81,7 @@ impl Grpc { T::ResponseBody: Body + HttpBody + Send + 'static, ::Error: Into, ::Data: Into, - S: Stream> + Send + 'static, + S: Stream + Send + 'static, C: Codec, M1: Send + 'static, M2: Send + 'static, @@ -118,7 +118,7 @@ impl Grpc { M1: Send + 'static, M2: Send + 'static, { - let request = request.map(|m| stream::once(future::ok(m))); + let request = request.map(|m| stream::once(future::ready(m))); self.streaming(request, path, codec).await } @@ -134,7 +134,7 @@ impl Grpc { T::ResponseBody: Body + HttpBody + Send + 'static, ::Data: Into, ::Error: Into, - S: Stream> + Send + 'static, + S: Stream + Send + 'static, C: Codec, M1: Send + 'static, M2: Send + 'static, diff --git a/tonic/src/codec/encode.rs b/tonic/src/codec/encode.rs index c157595f8..7d91b4b94 100644 --- a/tonic/src/codec/encode.rs +++ b/tonic/src/codec/encode.rs @@ -29,9 +29,9 @@ pub(crate) fn encode_client( ) -> EncodeBody>> where T: Encoder, - U: Stream>, + U: Stream, { - let stream = encode(encoder, source).into_stream(); + let stream = encode(encoder, source.map(|x| Ok(x))).into_stream(); EncodeBody::new_client(stream) }