Skip to content

Commit

Permalink
web-sys: Added Streams API (#3065)
Browse files Browse the repository at this point in the history
  • Loading branch information
rozbb committed Sep 6, 2022
1 parent 699e788 commit e47dda5
Show file tree
Hide file tree
Showing 32 changed files with 1,082 additions and 474 deletions.
15 changes: 13 additions & 2 deletions crates/web-sys/Cargo.toml
Expand Up @@ -150,6 +150,7 @@ BrowserElementExecuteScriptOptions = []
BrowserFeedWriter = []
BrowserFindCaseSensitivity = []
BrowserFindDirection = []
ByteLengthQueuingStrategy = []
Cache = []
CacheBatchOperation = []
CacheQueryOptions = []
Expand Down Expand Up @@ -223,6 +224,7 @@ ConvertCoordinateOptions = []
ConvolverNode = ["AudioNode", "EventTarget"]
ConvolverOptions = []
Coordinates = []
CountQueuingStrategy = []
Credential = []
CredentialCreationOptions = []
CredentialRequestOptions = []
Expand Down Expand Up @@ -973,18 +975,22 @@ PushSubscriptionKeys = []
PushSubscriptionOptions = []
PushSubscriptionOptionsInit = []
QueuingStrategy = []
QueuingStrategyInit = []
RadioNodeList = ["NodeList"]
Range = []
RcwnPerfStats = []
RcwnStatus = []
ReadableByteStreamController = []
ReadableStream = []
ReadableStreamByobReadResult = []
ReadableStreamByobReader = []
ReadableStreamDefaultReadResult = []
ReadableStreamByobRequest = []
ReadableStreamDefaultController = []
ReadableStreamDefaultReader = []
ReadableStreamGetReaderOptions = []
ReadableStreamIteratorOptions = []
ReadableStreamReadResult = []
ReadableStreamReaderMode = []
ReadableStreamType = []
ReadableWritablePair = []
RecordingState = []
ReferrerPolicy = []
Expand Down Expand Up @@ -1319,6 +1325,8 @@ TouchList = []
TrackEvent = ["Event"]
TrackEventInit = []
TransformStream = []
TransformStreamDefaultController = []
Transformer = []
TransitionEvent = ["Event"]
TransitionEventInit = []
Transport = []
Expand All @@ -1332,6 +1340,8 @@ UdpMessageEventInit = []
UdpOptions = []
UiEvent = ["Event"]
UiEventInit = []
UnderlyingSink = []
UnderlyingSource = []
Url = []
UrlSearchParams = []
Usb = ["EventTarget"]
Expand Down Expand Up @@ -1468,6 +1478,7 @@ Worklet = []
WorkletGlobalScope = []
WorkletOptions = []
WritableStream = []
WritableStreamDefaultController = []
WritableStreamDefaultWriter = []
XPathExpression = []
XPathNsResolver = []
Expand Down
36 changes: 36 additions & 0 deletions crates/web-sys/src/features/gen_ByteLengthQueuingStrategy.rs
@@ -0,0 +1,36 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = ByteLengthQueuingStrategy , typescript_type = "ByteLengthQueuingStrategy")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `ByteLengthQueuingStrategy` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ByteLengthQueuingStrategy)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ByteLengthQueuingStrategy`*"]
pub type ByteLengthQueuingStrategy;
# [wasm_bindgen (structural , method , getter , js_class = "ByteLengthQueuingStrategy" , js_name = highWaterMark)]
#[doc = "Getter for the `highWaterMark` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ByteLengthQueuingStrategy`*"]
pub fn high_water_mark(this: &ByteLengthQueuingStrategy) -> f64;
# [wasm_bindgen (structural , method , getter , js_class = "ByteLengthQueuingStrategy" , js_name = size)]
#[doc = "Getter for the `size` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ByteLengthQueuingStrategy/size)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ByteLengthQueuingStrategy`*"]
pub fn size(this: &ByteLengthQueuingStrategy) -> ::js_sys::Function;
#[cfg(feature = "QueuingStrategyInit")]
#[wasm_bindgen(catch, constructor, js_class = "ByteLengthQueuingStrategy")]
#[doc = "The `new ByteLengthQueuingStrategy(..)` constructor, creating a new instance of `ByteLengthQueuingStrategy`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ByteLengthQueuingStrategy/ByteLengthQueuingStrategy)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ByteLengthQueuingStrategy`, `QueuingStrategyInit`*"]
pub fn new(init: &QueuingStrategyInit) -> Result<ByteLengthQueuingStrategy, JsValue>;
}
36 changes: 36 additions & 0 deletions crates/web-sys/src/features/gen_CountQueuingStrategy.rs
@@ -0,0 +1,36 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = CountQueuingStrategy , typescript_type = "CountQueuingStrategy")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `CountQueuingStrategy` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CountQueuingStrategy)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CountQueuingStrategy`*"]
pub type CountQueuingStrategy;
# [wasm_bindgen (structural , method , getter , js_class = "CountQueuingStrategy" , js_name = highWaterMark)]
#[doc = "Getter for the `highWaterMark` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CountQueuingStrategy/highWaterMark)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CountQueuingStrategy`*"]
pub fn high_water_mark(this: &CountQueuingStrategy) -> f64;
# [wasm_bindgen (structural , method , getter , js_class = "CountQueuingStrategy" , js_name = size)]
#[doc = "Getter for the `size` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CountQueuingStrategy/size)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CountQueuingStrategy`*"]
pub fn size(this: &CountQueuingStrategy) -> ::js_sys::Function;
#[cfg(feature = "QueuingStrategyInit")]
#[wasm_bindgen(catch, constructor, js_class = "CountQueuingStrategy")]
#[doc = "The `new CountQueuingStrategy(..)` constructor, creating a new instance of `CountQueuingStrategy`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CountQueuingStrategy/CountQueuingStrategy)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CountQueuingStrategy`, `QueuingStrategyInit`*"]
pub fn new(init: &QueuingStrategyInit) -> Result<CountQueuingStrategy, JsValue>;
}
40 changes: 40 additions & 0 deletions crates/web-sys/src/features/gen_QueuingStrategyInit.rs
@@ -0,0 +1,40 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = QueuingStrategyInit)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `QueuingStrategyInit` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `QueuingStrategyInit`*"]
pub type QueuingStrategyInit;
}
impl QueuingStrategyInit {
#[doc = "Construct a new `QueuingStrategyInit`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `QueuingStrategyInit`*"]
pub fn new(high_water_mark: f64) -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret.high_water_mark(high_water_mark);
ret
}
#[doc = "Change the `highWaterMark` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `QueuingStrategyInit`*"]
pub fn high_water_mark(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("highWaterMark"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
70 changes: 70 additions & 0 deletions crates/web-sys/src/features/gen_ReadableByteStreamController.rs
@@ -0,0 +1,70 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = ReadableByteStreamController , typescript_type = "ReadableByteStreamController")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `ReadableByteStreamController` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ReadableByteStreamController`*"]
pub type ReadableByteStreamController;
#[cfg(feature = "ReadableStreamByobRequest")]
# [wasm_bindgen (structural , method , getter , js_class = "ReadableByteStreamController" , js_name = byobRequest)]
#[doc = "Getter for the `byobRequest` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController/byobRequest)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ReadableByteStreamController`, `ReadableStreamByobRequest`*"]
pub fn byob_request(this: &ReadableByteStreamController) -> Option<ReadableStreamByobRequest>;
# [wasm_bindgen (structural , method , getter , js_class = "ReadableByteStreamController" , js_name = desiredSize)]
#[doc = "Getter for the `desiredSize` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController/desiredSize)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ReadableByteStreamController`*"]
pub fn desired_size(this: &ReadableByteStreamController) -> Option<f64>;
# [wasm_bindgen (catch , method , structural , js_class = "ReadableByteStreamController" , js_name = close)]
#[doc = "The `close()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController/close)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ReadableByteStreamController`*"]
pub fn close(this: &ReadableByteStreamController) -> Result<(), JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "ReadableByteStreamController" , js_name = enqueue)]
#[doc = "The `enqueue()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController/enqueue)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ReadableByteStreamController`*"]
pub fn enqueue_with_array_buffer_view(
this: &ReadableByteStreamController,
chunk: &::js_sys::Object,
) -> Result<(), JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "ReadableByteStreamController" , js_name = enqueue)]
#[doc = "The `enqueue()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController/enqueue)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ReadableByteStreamController`*"]
pub fn enqueue_with_u8_array(
this: &ReadableByteStreamController,
chunk: &mut [u8],
) -> Result<(), JsValue>;
# [wasm_bindgen (method , structural , js_class = "ReadableByteStreamController" , js_name = error)]
#[doc = "The `error()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController/error)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ReadableByteStreamController`*"]
pub fn error(this: &ReadableByteStreamController);
# [wasm_bindgen (method , structural , js_class = "ReadableByteStreamController" , js_name = error)]
#[doc = "The `error()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController/error)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ReadableByteStreamController`*"]
pub fn error_with_e(this: &ReadableByteStreamController, e: &::wasm_bindgen::JsValue);
}
8 changes: 0 additions & 8 deletions crates/web-sys/src/features/gen_ReadableStream.rs
Expand Up @@ -112,29 +112,21 @@ extern "C" {
transform: &ReadableWritablePair,
options: &StreamPipeOptions,
) -> ReadableStream;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "WritableStream")]
# [wasm_bindgen (method , structural , js_class = "ReadableStream" , js_name = pipeTo)]
#[doc = "The `pipeTo()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/pipeTo)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ReadableStream`, `WritableStream`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn pipe_to(this: &ReadableStream, destination: &WritableStream) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
#[cfg(all(feature = "StreamPipeOptions", feature = "WritableStream",))]
# [wasm_bindgen (method , structural , js_class = "ReadableStream" , js_name = pipeTo)]
#[doc = "The `pipeTo()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/pipeTo)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ReadableStream`, `StreamPipeOptions`, `WritableStream`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn pipe_to_with_options(
this: &ReadableStream,
destination: &WritableStream,
Expand Down
70 changes: 0 additions & 70 deletions crates/web-sys/src/features/gen_ReadableStreamByobReadResult.rs

This file was deleted.

0 comments on commit e47dda5

Please sign in to comment.