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

Move streaming reader out of Blob into a dedicated BufReader class #197

Merged
merged 4 commits into from
Jan 20, 2025

Conversation

andreiltd
Copy link
Member

This patch extracts the streaming reader logic from Blob and into a new BufReader class. This change removes A LOT of clutter from Blob while clearly separating the streaming concerns into a dedicated component.

The BufReader encapsulates the asynchronous task of reading data from a underlying source. It takes a Read function as a constructor parameter, allowing callers to specify how bytes are fetched into the provided buffer. The Read function must return the number of bytes read and indicate completion by setting done when there is no more data to read.

This refactoring is a preparatory work for a streaming FormDataEncoder, as discussed here: #191 (comment).

Copy link
Member

@tschneidereit tschneidereit left a comment

Choose a reason for hiding this comment

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

This all makes sense to me, and it'll be great to be able to reuse things for streaming from FormData instances

@tschneidereit tschneidereit merged commit 39114a4 into bytecodealliance:main Jan 20, 2025
5 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.

2 participants