Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return impl AsyncBufRead from into_async_read #3164

Merged
merged 2 commits into from
Nov 10, 2023

Conversation

utkarshgupta137
Copy link
Contributor

Motivation and Context

The tokio StreamReader implements AsyncBufRead, but we're returning AsyncRead currently. If a user needs an AsyncBufRead, then they've to wrap the returned value in tokio BufReader for no reason. Since ByteStream doesn't implement Stream anymore, one has to either wrap the returned value unnecessarily or write a wrapper similar to this function.
See #2983 (comment).

Description

Simply changed the return type to say impl AsyncBufRead. Since AsyncBufRead is a super-set of AsyncRead, this is not a breaking change.

Testing

The code example tests it.

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Collaborator

@jdisanti jdisanti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this! ❤️

CHANGELOG.next.toml Outdated Show resolved Hide resolved
@jdisanti
Copy link
Collaborator

jdisanti commented Nov 9, 2023

It looks like the changes to the example aren't compiling:

 error[E0599]: no method named `lines` found for opaque type `impl tokio::io::async_buf_read::AsyncBufRead` in the current scope
   --> src\byte_stream.rs:434:50
    |
7   | let mut lines =  my_bytestream.into_async_read().lines();
    |                                                  ^^^^^ method not found in `impl AsyncBufRead`
    |
   ::: C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.33.0\src\io\util\async_buf_read_ext.rs:342:12
    |
342 |         fn lines(self) -> Lines<Self>
    |            ----- the method is available for `impl tokio::io::async_buf_read::AsyncBufRead` here
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
2   + use tokio::io::util::async_buf_read_ext::AsyncBufReadExt;
    |

error: aborting due to previous error

@utkarshgupta137 utkarshgupta137 force-pushed the main branch 2 times, most recently from 5ca448a to f9f9305 Compare November 9, 2023 19:11
@utkarshgupta137
Copy link
Contributor Author

It looks like the changes to the example aren't compiling:

 error[E0599]: no method named `lines` found for opaque type `impl tokio::io::async_buf_read::AsyncBufRead` in the current scope
   --> src\byte_stream.rs:434:50
    |
7   | let mut lines =  my_bytestream.into_async_read().lines();
    |                                                  ^^^^^ method not found in `impl AsyncBufRead`
    |
   ::: C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.33.0\src\io\util\async_buf_read_ext.rs:342:12
    |
342 |         fn lines(self) -> Lines<Self>
    |            ----- the method is available for `impl tokio::io::async_buf_read::AsyncBufRead` here
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
2   + use tokio::io::util::async_buf_read_ext::AsyncBufReadExt;
    |

error: aborting due to previous error

Fixed.

Fix path for async-buf read
@rcoh
Copy link
Collaborator

rcoh commented Nov 10, 2023

I fixed external types, CI should pass now I think

@ysaito1001 ysaito1001 added this pull request to the merge queue Nov 10, 2023
Merged via the queue into smithy-lang:main with commit 7f8fef2 Nov 10, 2023
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants