Skip to content

Commit

Permalink
web-sys: Add WebBluetooth to enabled directory
Browse files Browse the repository at this point in the history
Add WebBluetooth IDL (taken from WebBluetooth spec), as well as
generated files and feature updates.
  • Loading branch information
qdot committed Sep 17, 2020
1 parent 6dd8f1c commit a2655cd
Show file tree
Hide file tree
Showing 26 changed files with 2,278 additions and 1 deletion.
24 changes: 23 additions & 1 deletion crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ AesKeyAlgorithm = []
AesKeyGenParams = []
Algorithm = []
AlignSetting = []
AllowedBluetoothDevice = []
AnalyserNode = ["AudioNode", "EventTarget"]
AnalyserOptions = []
AngleInstancedArrays = []
Expand Down Expand Up @@ -111,6 +112,23 @@ BlobEvent = ["Event"]
BlobEventInit = []
BlobPropertyBag = []
BlockParsingOptions = []
Bluetooth = ["EventTarget"]
BluetoothAdvertisingEvent = ["Event"]
BluetoothAdvertisingEventInit = []
BluetoothCharacteristicProperties = []
BluetoothDataFilterInit = []
BluetoothDevice = ["EventTarget"]
BluetoothLeScanFilterInit = []
BluetoothManufacturerDataMap = []
BluetoothPermissionDescriptor = []
BluetoothPermissionResult = ["EventTarget", "PermissionStatus"]
BluetoothPermissionStorage = []
BluetoothRemoteGattCharacteristic = ["EventTarget"]
BluetoothRemoteGattDescriptor = []
BluetoothRemoteGattServer = []
BluetoothRemoteGattService = ["EventTarget"]
BluetoothServiceDataMap = []
BluetoothUuid = []
BoxQuadOptions = []
BroadcastChannel = ["EventTarget"]
BrowserElementDownloadOptions = []
Expand Down Expand Up @@ -892,6 +910,7 @@ Request = []
RequestCache = []
RequestCredentials = []
RequestDestination = []
RequestDeviceOptions = []
RequestInit = []
RequestMediaKeySystemAccessNotification = []
RequestMode = []
Expand Down Expand Up @@ -1222,6 +1241,8 @@ UserProximityEvent = ["Event"]
UserProximityEventInit = []
UserVerificationRequirement = []
ValidityState = []
ValueEvent = ["Event"]
ValueEventInit = []
VideoConfiguration = []
VideoFacingModeEnum = []
VideoPlaybackQuality = []
Expand All @@ -1245,6 +1266,7 @@ VrStageParameters = []
VrSubmitFrameResult = []
VttCue = ["EventTarget", "TextTrackCue"]
VttRegion = []
WatchAdvertisementsOptions = []
WaveShaperNode = ["AudioNode", "EventTarget"]
WaveShaperOptions = []
WebGl2RenderingContext = []
Expand Down Expand Up @@ -1342,4 +1364,4 @@ XrWebGlLayer = []
XrWebGlLayerInit = []
XsltProcessor = []
console = []
css = []
css = []
80 changes: 80 additions & 0 deletions crates/web-sys/src/features/gen_AllowedBluetoothDevice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AllowedBluetoothDevice)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `AllowedBluetoothDevice` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
pub type AllowedBluetoothDevice;
}
impl AllowedBluetoothDevice {
#[doc = "Construct a new `AllowedBluetoothDevice`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
pub fn new(
allowed_services: &::wasm_bindgen::JsValue,
device_id: &str,
may_use_gatt: bool,
) -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret.allowed_services(allowed_services);
ret.device_id(device_id);
ret.may_use_gatt(may_use_gatt);
ret
}
#[doc = "Change the `allowedServices` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
pub fn allowed_services(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("allowedServices"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `deviceId` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
pub fn device_id(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("deviceId"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `mayUseGATT` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
pub fn may_use_gatt(&mut self, val: bool) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("mayUseGATT"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
152 changes: 152 additions & 0 deletions crates/web-sys/src/features/gen_Bluetooth.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = EventTarget , extends = :: js_sys :: Object , js_name = Bluetooth , typescript_type = "Bluetooth")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `Bluetooth` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub type Bluetooth;
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = onavailabilitychanged)]
#[doc = "Getter for the `onavailabilitychanged` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onavailabilitychanged)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn onavailabilitychanged(this: &Bluetooth) -> Option<::js_sys::Function>;
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = onavailabilitychanged)]
#[doc = "Setter for the `onavailabilitychanged` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onavailabilitychanged)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn set_onavailabilitychanged(this: &Bluetooth, value: Option<&::js_sys::Function>);
#[cfg(feature = "BluetoothDevice")]
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = referringDevice)]
#[doc = "Getter for the `referringDevice` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/referringDevice)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`, `BluetoothDevice`*"]
pub fn referring_device(this: &Bluetooth) -> Option<BluetoothDevice>;
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = onadvertisementreceived)]
#[doc = "Getter for the `onadvertisementreceived` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onadvertisementreceived)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn onadvertisementreceived(this: &Bluetooth) -> Option<::js_sys::Function>;
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = onadvertisementreceived)]
#[doc = "Setter for the `onadvertisementreceived` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onadvertisementreceived)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn set_onadvertisementreceived(this: &Bluetooth, value: Option<&::js_sys::Function>);
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = ongattserverdisconnected)]
#[doc = "Getter for the `ongattserverdisconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/ongattserverdisconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn ongattserverdisconnected(this: &Bluetooth) -> Option<::js_sys::Function>;
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = ongattserverdisconnected)]
#[doc = "Setter for the `ongattserverdisconnected` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/ongattserverdisconnected)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn set_ongattserverdisconnected(this: &Bluetooth, value: Option<&::js_sys::Function>);
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = oncharacteristicvaluechanged)]
#[doc = "Getter for the `oncharacteristicvaluechanged` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/oncharacteristicvaluechanged)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn oncharacteristicvaluechanged(this: &Bluetooth) -> Option<::js_sys::Function>;
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = oncharacteristicvaluechanged)]
#[doc = "Setter for the `oncharacteristicvaluechanged` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/oncharacteristicvaluechanged)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn set_oncharacteristicvaluechanged(this: &Bluetooth, value: Option<&::js_sys::Function>);
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = onserviceadded)]
#[doc = "Getter for the `onserviceadded` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onserviceadded)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn onserviceadded(this: &Bluetooth) -> Option<::js_sys::Function>;
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = onserviceadded)]
#[doc = "Setter for the `onserviceadded` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onserviceadded)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn set_onserviceadded(this: &Bluetooth, value: Option<&::js_sys::Function>);
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = onservicechanged)]
#[doc = "Getter for the `onservicechanged` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onservicechanged)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn onservicechanged(this: &Bluetooth) -> Option<::js_sys::Function>;
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = onservicechanged)]
#[doc = "Setter for the `onservicechanged` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onservicechanged)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn set_onservicechanged(this: &Bluetooth, value: Option<&::js_sys::Function>);
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = onserviceremoved)]
#[doc = "Getter for the `onserviceremoved` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onserviceremoved)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn onserviceremoved(this: &Bluetooth) -> Option<::js_sys::Function>;
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = onserviceremoved)]
#[doc = "Setter for the `onserviceremoved` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onserviceremoved)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn set_onserviceremoved(this: &Bluetooth, value: Option<&::js_sys::Function>);
# [wasm_bindgen (method , structural , js_class = "Bluetooth" , js_name = getAvailability)]
#[doc = "The `getAvailability()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getAvailability)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn get_availability(this: &Bluetooth) -> ::js_sys::Promise;
# [wasm_bindgen (method , structural , js_class = "Bluetooth" , js_name = getDevices)]
#[doc = "The `getDevices()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn get_devices(this: &Bluetooth) -> ::js_sys::Promise;
# [wasm_bindgen (method , structural , js_class = "Bluetooth" , js_name = requestDevice)]
#[doc = "The `requestDevice()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
pub fn request_device(this: &Bluetooth) -> ::js_sys::Promise;
#[cfg(feature = "RequestDeviceOptions")]
# [wasm_bindgen (method , structural , js_class = "Bluetooth" , js_name = requestDevice)]
#[doc = "The `requestDevice()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`, `RequestDeviceOptions`*"]
pub fn request_device_with_options(
this: &Bluetooth,
options: &RequestDeviceOptions,
) -> ::js_sys::Promise;
}
66 changes: 66 additions & 0 deletions crates/web-sys/src/features/gen_BluetoothAdvertisingEvent.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = Event , extends = :: js_sys :: Object , js_name = BluetoothAdvertisingEvent , typescript_type = "BluetoothAdvertisingEvent")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `BluetoothAdvertisingEvent` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`*"]
pub type BluetoothAdvertisingEvent;
#[cfg(feature = "BluetoothDevice")]
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = device)]
#[doc = "Getter for the `device` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/device)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`, `BluetoothDevice`*"]
pub fn device(this: &BluetoothAdvertisingEvent) -> BluetoothDevice;
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = name)]
#[doc = "Getter for the `name` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/name)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`*"]
pub fn name(this: &BluetoothAdvertisingEvent) -> Option<String>;
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = appearance)]
#[doc = "Getter for the `appearance` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/appearance)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`*"]
pub fn appearance(this: &BluetoothAdvertisingEvent) -> Option<u16>;
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = txPower)]
#[doc = "Getter for the `txPower` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/txPower)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`*"]
pub fn tx_power(this: &BluetoothAdvertisingEvent) -> Option<i8>;
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = rssi)]
#[doc = "Getter for the `rssi` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/rssi)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`*"]
pub fn rssi(this: &BluetoothAdvertisingEvent) -> Option<i8>;
#[cfg(feature = "BluetoothManufacturerDataMap")]
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = manufacturerData)]
#[doc = "Getter for the `manufacturerData` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/manufacturerData)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`, `BluetoothManufacturerDataMap`*"]
pub fn manufacturer_data(this: &BluetoothAdvertisingEvent) -> BluetoothManufacturerDataMap;
#[cfg(feature = "BluetoothServiceDataMap")]
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = serviceData)]
#[doc = "Getter for the `serviceData` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/serviceData)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`, `BluetoothServiceDataMap`*"]
pub fn service_data(this: &BluetoothAdvertisingEvent) -> BluetoothServiceDataMap;
}
Loading

0 comments on commit a2655cd

Please sign in to comment.