Skip to content

Commit d639960

Browse files
authored
Add WebBluetooth to unstable directory (#2311)
Add WebBluetooth IDL (taken from WebBluetooth spec), as well as generated files and feature updates. Currently in unstable as WebBluetooth is not on standards track yet.
1 parent 6dd8f1c commit d639960

26 files changed

+3006
-1
lines changed

crates/web-sys/Cargo.toml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ AesKeyAlgorithm = []
4141
AesKeyGenParams = []
4242
Algorithm = []
4343
AlignSetting = []
44+
AllowedBluetoothDevice = []
4445
AnalyserNode = ["AudioNode", "EventTarget"]
4546
AnalyserOptions = []
4647
AngleInstancedArrays = []
@@ -111,6 +112,23 @@ BlobEvent = ["Event"]
111112
BlobEventInit = []
112113
BlobPropertyBag = []
113114
BlockParsingOptions = []
115+
Bluetooth = ["EventTarget"]
116+
BluetoothAdvertisingEvent = ["Event"]
117+
BluetoothAdvertisingEventInit = []
118+
BluetoothCharacteristicProperties = []
119+
BluetoothDataFilterInit = []
120+
BluetoothDevice = ["EventTarget"]
121+
BluetoothLeScanFilterInit = []
122+
BluetoothManufacturerDataMap = []
123+
BluetoothPermissionDescriptor = []
124+
BluetoothPermissionResult = ["EventTarget", "PermissionStatus"]
125+
BluetoothPermissionStorage = []
126+
BluetoothRemoteGattCharacteristic = ["EventTarget"]
127+
BluetoothRemoteGattDescriptor = []
128+
BluetoothRemoteGattServer = []
129+
BluetoothRemoteGattService = ["EventTarget"]
130+
BluetoothServiceDataMap = []
131+
BluetoothUuid = []
114132
BoxQuadOptions = []
115133
BroadcastChannel = ["EventTarget"]
116134
BrowserElementDownloadOptions = []
@@ -892,6 +910,7 @@ Request = []
892910
RequestCache = []
893911
RequestCredentials = []
894912
RequestDestination = []
913+
RequestDeviceOptions = []
895914
RequestInit = []
896915
RequestMediaKeySystemAccessNotification = []
897916
RequestMode = []
@@ -1222,6 +1241,8 @@ UserProximityEvent = ["Event"]
12221241
UserProximityEventInit = []
12231242
UserVerificationRequirement = []
12241243
ValidityState = []
1244+
ValueEvent = ["Event"]
1245+
ValueEventInit = []
12251246
VideoConfiguration = []
12261247
VideoFacingModeEnum = []
12271248
VideoPlaybackQuality = []
@@ -1245,6 +1266,7 @@ VrStageParameters = []
12451266
VrSubmitFrameResult = []
12461267
VttCue = ["EventTarget", "TextTrackCue"]
12471268
VttRegion = []
1269+
WatchAdvertisementsOptions = []
12481270
WaveShaperNode = ["AudioNode", "EventTarget"]
12491271
WaveShaperOptions = []
12501272
WebGl2RenderingContext = []
@@ -1342,4 +1364,4 @@ XrWebGlLayer = []
13421364
XrWebGlLayerInit = []
13431365
XsltProcessor = []
13441366
console = []
1345-
css = []
1367+
css = []
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#![allow(unused_imports)]
2+
use super::*;
3+
use wasm_bindgen::prelude::*;
4+
#[cfg(web_sys_unstable_apis)]
5+
#[wasm_bindgen]
6+
extern "C" {
7+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AllowedBluetoothDevice)]
8+
#[derive(Debug, Clone, PartialEq, Eq)]
9+
#[doc = "The `AllowedBluetoothDevice` dictionary."]
10+
#[doc = ""]
11+
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
12+
#[doc = ""]
13+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
14+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
15+
pub type AllowedBluetoothDevice;
16+
}
17+
#[cfg(web_sys_unstable_apis)]
18+
impl AllowedBluetoothDevice {
19+
#[doc = "Construct a new `AllowedBluetoothDevice`."]
20+
#[doc = ""]
21+
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
22+
#[doc = ""]
23+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
24+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
25+
pub fn new(
26+
allowed_services: &::wasm_bindgen::JsValue,
27+
device_id: &str,
28+
may_use_gatt: bool,
29+
) -> Self {
30+
#[allow(unused_mut)]
31+
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
32+
ret.allowed_services(allowed_services);
33+
ret.device_id(device_id);
34+
ret.may_use_gatt(may_use_gatt);
35+
ret
36+
}
37+
#[cfg(web_sys_unstable_apis)]
38+
#[doc = "Change the `allowedServices` field of this object."]
39+
#[doc = ""]
40+
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
41+
#[doc = ""]
42+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
43+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
44+
pub fn allowed_services(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
45+
use wasm_bindgen::JsValue;
46+
let r = ::js_sys::Reflect::set(
47+
self.as_ref(),
48+
&JsValue::from("allowedServices"),
49+
&JsValue::from(val),
50+
);
51+
debug_assert!(
52+
r.is_ok(),
53+
"setting properties should never fail on our dictionary objects"
54+
);
55+
let _ = r;
56+
self
57+
}
58+
#[cfg(web_sys_unstable_apis)]
59+
#[doc = "Change the `deviceId` field of this object."]
60+
#[doc = ""]
61+
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
62+
#[doc = ""]
63+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
64+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
65+
pub fn device_id(&mut self, val: &str) -> &mut Self {
66+
use wasm_bindgen::JsValue;
67+
let r = ::js_sys::Reflect::set(
68+
self.as_ref(),
69+
&JsValue::from("deviceId"),
70+
&JsValue::from(val),
71+
);
72+
debug_assert!(
73+
r.is_ok(),
74+
"setting properties should never fail on our dictionary objects"
75+
);
76+
let _ = r;
77+
self
78+
}
79+
#[cfg(web_sys_unstable_apis)]
80+
#[doc = "Change the `mayUseGATT` field of this object."]
81+
#[doc = ""]
82+
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
83+
#[doc = ""]
84+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
85+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
86+
pub fn may_use_gatt(&mut self, val: bool) -> &mut Self {
87+
use wasm_bindgen::JsValue;
88+
let r = ::js_sys::Reflect::set(
89+
self.as_ref(),
90+
&JsValue::from("mayUseGATT"),
91+
&JsValue::from(val),
92+
);
93+
debug_assert!(
94+
r.is_ok(),
95+
"setting properties should never fail on our dictionary objects"
96+
);
97+
let _ = r;
98+
self
99+
}
100+
}

0 commit comments

Comments
 (0)