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

Added WebUSB API #2345

Merged
merged 1 commit into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ AesKeyGenParams = []
Algorithm = []
AlignSetting = []
AllowedBluetoothDevice = []
AllowedUsbDevice = []
AnalyserNode = ["AudioNode", "EventTarget"]
AnalyserOptions = []
AngleInstancedArrays = []
Expand Down Expand Up @@ -247,7 +248,6 @@ CustomEventInit = []
DataTransfer = []
DataTransferItem = []
DataTransferItemList = []
DataView = []
DateTimeValue = []
DecoderDoctorNotification = []
DecoderDoctorNotificationType = []
Expand Down Expand Up @@ -1238,6 +1238,31 @@ UiEvent = ["Event"]
UiEventInit = []
Url = []
UrlSearchParams = []
Usb = ["EventTarget"]
UsbAlternateInterface = []
UsbConfiguration = []
UsbConnectionEvent = ["Event"]
UsbConnectionEventInit = []
UsbControlTransferParameters = []
UsbDevice = []
UsbDeviceFilter = []
UsbDeviceRequestOptions = []
UsbDirection = []
UsbEndpoint = []
UsbEndpointType = []
UsbInTransferResult = []
UsbInterface = []
UsbIsochronousInTransferPacket = []
UsbIsochronousInTransferResult = []
UsbIsochronousOutTransferPacket = []
UsbIsochronousOutTransferResult = []
UsbOutTransferResult = []
UsbPermissionDescriptor = []
UsbPermissionResult = ["EventTarget", "PermissionStatus"]
UsbPermissionStorage = []
UsbRecipient = []
UsbRequestType = []
UsbTransferStatus = []
UserProximityEvent = ["Event"]
UserProximityEventInit = []
UserVerificationRequirement = []
Expand Down
95 changes: 95 additions & 0 deletions crates/web-sys/src/features/gen_AllowedUsbDevice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AllowedUSBDevice)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `AllowedUsbDevice` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AllowedUsbDevice`*"]
#[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 type AllowedUsbDevice;
}
#[cfg(web_sys_unstable_apis)]
impl AllowedUsbDevice {
#[doc = "Construct a new `AllowedUsbDevice`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AllowedUsbDevice`*"]
#[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 new(product_id: u8, vendor_id: u8) -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret.product_id(product_id);
ret.vendor_id(vendor_id);
ret
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `productId` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AllowedUsbDevice`*"]
#[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 product_id(&mut self, val: u8) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("productId"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `serialNumber` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AllowedUsbDevice`*"]
#[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 serial_number(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("serialNumber"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `vendorId` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AllowedUsbDevice`*"]
#[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 vendor_id(&mut self, val: u8) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("vendorId"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
11 changes: 11 additions & 0 deletions crates/web-sys/src/features/gen_BluetoothAdvertisingEvent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ extern "C" {
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn device(this: &BluetoothAdvertisingEvent) -> BluetoothDevice;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = uuids)]
#[doc = "Getter for the `uuids` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/uuids)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`*"]
#[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 uuids(this: &BluetoothAdvertisingEvent) -> ::js_sys::Array;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = name)]
#[doc = "Getter for the `name` field of this object."]
#[doc = ""]
Expand Down
22 changes: 22 additions & 0 deletions crates/web-sys/src/features/gen_BluetoothPermissionResult.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,26 @@ extern "C" {
#[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 type BluetoothPermissionResult;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothPermissionResult" , js_name = devices)]
#[doc = "Getter for the `devices` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothPermissionResult/devices)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothPermissionResult`*"]
#[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 devices(this: &BluetoothPermissionResult) -> ::js_sys::Array;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , setter , js_class = "BluetoothPermissionResult" , js_name = devices)]
#[doc = "Setter for the `devices` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothPermissionResult/devices)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothPermissionResult`*"]
#[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 set_devices(this: &BluetoothPermissionResult, value: &::wasm_bindgen::JsValue);
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ extern "C" {
this: &BluetoothRemoteGattCharacteristic,
) -> BluetoothCharacteristicProperties;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "DataView")]
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothRemoteGATTCharacteristic" , js_name = value)]
#[doc = "Getter for the `value` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothRemoteGATTCharacteristic/value)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothRemoteGattCharacteristic`, `DataView`*"]
#[doc = "*This API requires the following crate features to be activated: `BluetoothRemoteGattCharacteristic`*"]
#[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)*"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ extern "C" {
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn uuid(this: &BluetoothRemoteGattDescriptor) -> String;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "DataView")]
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothRemoteGATTDescriptor" , js_name = value)]
#[doc = "Getter for the `value` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothRemoteGATTDescriptor/value)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothRemoteGattDescriptor`, `DataView`*"]
#[doc = "*This API requires the following crate features to be activated: `BluetoothRemoteGattDescriptor`*"]
#[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)*"]
Expand Down
11 changes: 11 additions & 0 deletions crates/web-sys/src/features/gen_ClipboardItem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ extern "C" {
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn delayed(this: &ClipboardItem) -> bool;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "ClipboardItem" , js_name = types)]
#[doc = "Getter for the `types` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/types)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"]
#[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 types(this: &ClipboardItem) -> ::js_sys::Array;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "ClipboardItem" , js_name = getType)]
#[doc = "The `getType()` method."]
#[doc = ""]
Expand Down
11 changes: 11 additions & 0 deletions crates/web-sys/src/features/gen_GpuAdapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ extern "C" {
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn name(this: &GpuAdapter) -> String;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "GPUAdapter" , js_name = extensions)]
#[doc = "Getter for the `extensions` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter/extensions)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuAdapter`*"]
#[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 extensions(this: &GpuAdapter) -> ::js_sys::Array;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "GPUAdapter" , js_name = requestDevice)]
#[doc = "The `requestDevice()` method."]
#[doc = ""]
Expand Down
11 changes: 11 additions & 0 deletions crates/web-sys/src/features/gen_GpuCompilationInfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,15 @@ extern "C" {
#[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 type GpuCompilationInfo;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "GPUCompilationInfo" , js_name = messages)]
#[doc = "Getter for the `messages` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCompilationInfo/messages)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuCompilationInfo`*"]
#[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 messages(this: &GpuCompilationInfo) -> ::js_sys::Array;
}
11 changes: 11 additions & 0 deletions crates/web-sys/src/features/gen_GpuDevice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ extern "C" {
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn adapter(this: &GpuDevice) -> GpuAdapter;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "GPUDevice" , js_name = extensions)]
#[doc = "Getter for the `extensions` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/extensions)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuDevice`*"]
#[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 extensions(this: &GpuDevice) -> ::js_sys::Array;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "GPUDevice" , js_name = limits)]
#[doc = "Getter for the `limits` field of this object."]
#[doc = ""]
Expand Down
12 changes: 12 additions & 0 deletions crates/web-sys/src/features/gen_Navigator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ extern "C" {
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn gpu(this: &Navigator) -> Gpu;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "Usb")]
# [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = usb)]
#[doc = "Getter for the `usb` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/usb)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Navigator`, `Usb`*"]
#[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 usb(this: &Navigator) -> Usb;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "Xr")]
# [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = xr)]
#[doc = "Getter for the `xr` field of this object."]
Expand Down
Loading