add some futures_core::stream::Stream impls for AsyncInputStream#80
Merged
add some futures_core::stream::Stream impls for AsyncInputStream#80
Conversation
teohhanhui
reviewed
Aug 8, 2025
| /// items of `Result<Vec<u8>, std::io::Error>`. The returned byte vectors | ||
| /// will be at most 8k. If you want to control chunk size, use | ||
| /// `Self::into_stream_of`. | ||
| pub fn into_stream(self) -> AsyncInputChunkStream { |
Contributor
There was a problem hiding this comment.
Calling into_stream() on an AsyncInputStream feels odd. 😆
Could this instead be:
impl AsyncInputChunkStream {
pub fn new(stream: AsyncInputStream) -> Self {
Self {
stream,
chunk_size: 8 * 1024,
}
}
pub fn with_size(stream: AsyncInputStream, chunk_size: usize) -> Self {
Self {
stream,
chunk_size,
}
}
}which makes it somewhat analogous to Vec::new and Vec::with_capacity
Contributor
Author
There was a problem hiding this comment.
I don't think anyone wants to think about AsyncInputChunkStream as a type itself, I would make it a private type and just return impl Stream<Item = ...> since that is all that matters, except we need to return a concrete type in case the user wants the into_inner method on the ChunkStream/ByteStream. I don't think the analogy to Vec really holds much water.
c4d90f6 to
e781d6b
Compare
Merged
yoshuawuyts
approved these changes
Oct 9, 2025
and also make AsyncInputStream Send and Sync by switching the internal OnceCell to OnceLock.
92a2d27 to
24cf772
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP: This PR still needs some tests
Closes #77