From 5ca448a308b65a2e51fe02357dffc481803e4b41 Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta <utkarshgupta137@gmail.com> Date: Thu, 9 Nov 2023 18:31:49 +0000 Subject: [PATCH] Return impl AsyncBufRead from into_async_read --- CHANGELOG.next.toml | 6 ++++++ rust-runtime/aws-smithy-types/src/byte_stream.rs | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 79f95dc718..6dbba7e62b 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -17,6 +17,12 @@ references = ["smithy-rs#3126", "aws-sdk-rust#930"] meta = { "breaking" = false, "tada" = false, "bug" = true } author = "rcoh" +[[aws-sdk-rust]] +message = "Change `ByteStream::into_async_read` to return `AsyncBufRead`" +references = ["smithy-rs#3164"] +meta = { "breaking" = false, "tada" = false, "bug" = true } +author = "utkarshgupta137" + [[smithy-rs]] message = "The HTTP `Request`, `Response`, `Headers`, and `HeaderValue` types have been moved from `aws_smithy_runtime_api::client::http::*` into `aws_smithy_runtime_api::http`" references = ["smithy-rs#3138"] diff --git a/rust-runtime/aws-smithy-types/src/byte_stream.rs b/rust-runtime/aws-smithy-types/src/byte_stream.rs index ac4329b3ed..eea1316b55 100644 --- a/rust-runtime/aws-smithy-types/src/byte_stream.rs +++ b/rust-runtime/aws-smithy-types/src/byte_stream.rs @@ -428,18 +428,17 @@ impl ByteStream { /// # Example /// /// ```rust - /// use tokio::io::{BufReader, AsyncBufReadExt}; /// use aws_smithy_types::byte_stream::ByteStream; /// /// # async fn dox(my_bytestream: ByteStream) -> std::io::Result<()> { - /// let mut lines = BufReader::new(my_bytestream.into_async_read()).lines(); + /// let mut lines = my_bytestream.into_async_read().lines(); /// while let Some(line) = lines.next_line().await? { /// // Do something line by line /// } /// # Ok(()) /// # } /// ``` - pub fn into_async_read(self) -> impl tokio::io::AsyncRead { + pub fn into_async_read(self) -> impl tokio::io::AsyncBufRead { // The `Stream` trait is currently unstable so we can only use it in private. // Here, we create a local struct just to enable the trait for `ByteStream` and pass it // to `StreamReader`.