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

Add WritableStream::into_async_write #10

Merged
merged 30 commits into from
Dec 9, 2021
Merged

Conversation

MattiasBuelens
Copy link
Owner

@MattiasBuelens MattiasBuelens commented Dec 2, 2021

This adds a way to turn a JS WritableStream into a Rust AsyncWrite.

Note that AsyncWrite passes a borrowed byte slice (&'a [u8]) to poll_write, whereas a WritableStream expects an "owned" Uint8Array. Therefore, we need to copy each given slice into a newly allocated Uint8Array. There's currently no way to avoid this copy, since JS doesn't yet have a concept of "writable byte streams" with BYOB semantics. (When such a concept is added in the future, we should be able to update our AsyncWrite implementation to use such a BYOB writer instead.)

Fixes #9.

@MattiasBuelens MattiasBuelens added this to the v0.2.2 milestone Dec 2, 2021
@MattiasBuelens MattiasBuelens added the enhancement New feature or request label Dec 2, 2021
@MattiasBuelens MattiasBuelens merged commit 9a33f0a into master Dec 9, 2021
@MattiasBuelens MattiasBuelens deleted the into-async-write branch December 9, 2021 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support converting WritableStream to AsyncWrite
1 participant