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

feat: add new web lock api interface #3604

Merged
merged 5 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
40 changes: 40 additions & 0 deletions crates/web-sys/src/features/gen_Lock.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = Lock , typescript_type = "Lock")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `Lock` class."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Lock`*"]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Lock)"]
#[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 LockManager;
# [wasm_bindgen (structural , method , getter , js_class = "Lock" , js_name = mode)]
#[feature = "LockMode"]
#[doc = "Getter for the `mode` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Lock/mode)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Lock`*"]
#[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 mode(this: &Lock) -> LockMode;
# [wasm_bindgen (structural , method , getter , js_class = "Lock" , 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/Lock/name)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Lock`*"]
#[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 name(this: &Lock) -> String;
}
99 changes: 99 additions & 0 deletions crates/web-sys/src/features/gen_LockInfo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = LockInfo)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `LockInfo` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockInfo`*"]
#[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 LockInfo;
}
#[cfg(web_sys_unstable_apis)]
impl LockInfo {
#[doc = "Construct a new `LockInfo`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockInfo`*"]
#[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() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `name` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockInfo`*"]
#[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 name(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("name"),
&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)]
#[feature = "LockMode"]
#[doc = "Change the `mode` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockInfo`*"]
#[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 mode(&mut self, val: LockMode) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("mode"),
&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 `clientId` field of this object."]
#[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 clientId(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("clientId"),
&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)]
impl Default for LockInfo{
fn default() -> Self {
Self::new()
}
}
54 changes: 54 additions & 0 deletions crates/web-sys/src/features/gen_LockManager.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = LockManager , typescript_type = "LockManager")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `LockManager` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/LockManager)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockManager`*"]
#[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 LockManager;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "LockManager" , js_name = request)]
#[doc = "The `request()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockManager`*"]
#[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 request(this: &LockManager, callback: &::js_sys::Function) -> js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "LockOptions")]
# [wasm_bindgen (method , structural , js_class = "LockManager" , js_name = request)]
#[doc = "The `request()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockManager`*"]
#[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 request_with_option(this: &LockManager, option: &LockOptions, callback: &::js_sys::Function) -> js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "LockManagerSnapshot")]
# [wasm_bindgen (method , structural , js_class = "LockManager" , js_name = query)]
#[doc = "The `request()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/LockManager/query)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockManager`*"]
#[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 query(this: &LockManager) -> js_sys::Promise;
}
76 changes: 76 additions & 0 deletions crates/web-sys/src/features/gen_LockManagerSnapshot.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = LockManagerSnapshot)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `LockManagerSnapshot` dictionary."]
pub type LockManagerSnapshot;
}
#[cfg(web_sys_unstable_apis)]
impl LockOptions {
#[doc = "Construct a new `LockManagerSnapshot`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockManagerSnapshot`*"]
#[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() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "LockInfo")]
#[doc = "Change the `held` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockManagerSnapshot`*"]
#[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 held(&mut self, val: &Vec<LockInfo>) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("ifAvaiable"),
&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)]
#[cfg(feature = "LockInfo")]
#[doc = "Change the `pending` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockManagerSnapshot`*"]
#[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 pending(&mut self, val: &Vec<LockInfo>) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("pending"),
&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)]
impl Default for LockManagerSnapshot{
fn default() -> Self {
Self::new()
}
}
16 changes: 16 additions & 0 deletions crates/web-sys/src/features/gen_LockMode.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
#[doc = "The `LockMode` enum."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockMode`*"]
#[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)*"]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LockMode {
Shared = "shared",
Exclusive = "exclusive"
}
104 changes: 104 additions & 0 deletions crates/web-sys/src/features/gen_LockOptions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = WebLockOptions)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `LockOptions` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockOption`*"]
#[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 LockOptions;
}
#[cfg(web_sys_unstable_apis)]
impl LockOptions {
#[doc = "Construct a new `LockOptions`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockOption`*"]
#[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() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "LockMode")]
#[doc = "Change the `mode` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `LockOption`*"]
#[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 mode(&mut self, val: LockMode) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("mode"), &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 `ifAvailable` field of this object."]
#[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 ifAvailable(&mut self, val: bool) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("ifAvaiable"),
&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 `steal` field of this object."]
pub fn steal(&mut self, val: bool) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("steal"),
&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)]
#[cfg(feature = "AbortSignal")]
#[doc = "Change the `signal` field of this object."]
pub fn signal(&mut self, val: &AbortSignal) -> &mut Self {
use wasm_bindgen::JsValue;
let r =
::js_sys::Reflect::set(self.as_ref(), &JsValue::from("signal"), &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)]
impl Default for WebLockOptions{
fn default() -> Self {
Self::new()
}
}
Loading