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

Enabling more Stream functionality #2584

Merged
merged 1 commit into from Jun 17, 2021

Conversation

halzy
Copy link
Contributor

@halzy halzy commented Jun 11, 2021

This PR is rebased it off of the PR #2586 so that it's easier to see what that PR does.

This is useful when compiling to WASM for the Cloudflare Workers:
https://developers.cloudflare.com/workers/runtime-apis/streams

Added Unstable WebIDL:
unstable/ReadableStreamDefaultReader.webidl
unstable/ReadableStreamGenericReader.webidl
unstable/QueuingStrategy.webidl
unstable/ReadableStreamBYOBReader.webidl
unstable/TransformStream.webidl
unstable/WritableStream.webidl
unstable/WritableStreamDefaultWriter.webidl

@@ -1237,6 +1243,7 @@ TouchInit = []
TouchList = []
TrackEvent = ["Event"]
TrackEventInit = []
TransformStream = ["ReadableStream", "WritableStream"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TransformStream is useless without these.

let _ = r;
self
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This type isn't created by the API user. It would benefit from #1793 and the setters are not useful.

let _ = r;
self
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here, not constructed by user, needs getters not setters.

@alexcrichton
Copy link
Contributor

Seems reasonable to me! I don't know anything about these APIs myself so I'd basically just be trusting you about the stable/unstable. Was there anything else you wanted to do here before merging though?

@halzy
Copy link
Contributor Author

halzy commented Jun 14, 2021

Seems reasonable to me! I don't know anything about these APIs myself so I'd basically just be trusting you about the stable/unstable. Was there anything else you wanted to do here before merging though?

@alexcrichton I've had a hard time determining how stable they are. The spec is a living standard and I've been relying on MDN to know if they're 'experimental' or not. After reviewing them again, I'll move them all to unstable as MDN lists the methods of ReadableStreamDefaultReader as experimental.

@halzy halzy force-pushed the halzy/streams_part_deux branch 2 times, most recently from d5c12fa to 5119a7b Compare June 14, 2021 15:57
This is useful when compiling to WASM for the Cloudflare Workers:
https://developers.cloudflare.com/workers/runtime-apis/streams

Added Unstable WebIDL:
   unstable/ReadableStreamDefaultReader.webidl
   unstable/ReadableStreamGenericReader.webidl
   unstable/QueuingStrategy.webidl
   unstable/ReadableStreamBYOBReader.webidl
   unstable/TransformStream.webidl
   unstable/WritableStream.webidl
   unstable/WritableStreamDefaultWriter.webidl
@halzy halzy closed this Jun 15, 2021
@halzy halzy reopened this Jun 15, 2021
@halzy
Copy link
Contributor Author

halzy commented Jun 15, 2021

I believe this is in a good state for merging now.

@alexcrichton
Copy link
Contributor

This is unfortunately a breaking change to the get_reader and get_reader_with_options APIs. Is there a way to avoid that? Or otherwise do you think it's ok to break things?

@halzy
Copy link
Contributor Author

halzy commented Jun 16, 2021

This is unfortunately a breaking change to the get_reader and get_reader_with_options APIs. Is there a way to avoid that? Or otherwise do you think it's ok to break things?

If a return type is not know to the code generator, it'll return a JsValue. When those types are then known, the return types should change because it's more correct. But what if the return type happens to be unstable?

If the return type is unstable we could mark the function as unstable, but that could then take a stable function that had unknown return types and make it unstable. That seems undesirable.

In this case we're lucky that there are 2 return types possible and the code generator end up resolving to Object. I think it's OK to break this as it's more correct. Users were likely casting from JsValue into either of those unstable types that they hand-rolled in their own project.

@alexcrichton
Copy link
Contributor

Ok seems reasonable to me! This defintely seems like a bug in the code generator though...

@alexcrichton alexcrichton merged commit 316b0ce into rustwasm:master Jun 17, 2021
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.

None yet

2 participants