maxcountryman_web_sys/features/
gen_SocketOptions.rs

1#![allow(unused_imports)]
2use super::*;
3use wasm_bindgen::prelude::*;
4#[wasm_bindgen]
5extern "C" {
6    # [wasm_bindgen (extends = :: js_sys :: Object , js_name = SocketOptions)]
7    #[derive(Debug, Clone, PartialEq, Eq)]
8    #[doc = "The `SocketOptions` dictionary."]
9    #[doc = ""]
10    #[doc = "*This API requires the following crate features to be activated: `SocketOptions`*"]
11    pub type SocketOptions;
12}
13impl SocketOptions {
14    #[doc = "Construct a new `SocketOptions`."]
15    #[doc = ""]
16    #[doc = "*This API requires the following crate features to be activated: `SocketOptions`*"]
17    pub fn new() -> Self {
18        #[allow(unused_mut)]
19        let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
20        ret
21    }
22    #[cfg(feature = "TcpSocketBinaryType")]
23    #[doc = "Change the `binaryType` field of this object."]
24    #[doc = ""]
25    #[doc = "*This API requires the following crate features to be activated: `SocketOptions`, `TcpSocketBinaryType`*"]
26    pub fn binary_type(&mut self, val: TcpSocketBinaryType) -> &mut Self {
27        use wasm_bindgen::JsValue;
28        let r = ::js_sys::Reflect::set(
29            self.as_ref(),
30            &JsValue::from("binaryType"),
31            &JsValue::from(val),
32        );
33        debug_assert!(
34            r.is_ok(),
35            "setting properties should never fail on our dictionary objects"
36        );
37        let _ = r;
38        self
39    }
40    #[doc = "Change the `useSecureTransport` field of this object."]
41    #[doc = ""]
42    #[doc = "*This API requires the following crate features to be activated: `SocketOptions`*"]
43    pub fn use_secure_transport(&mut self, val: bool) -> &mut Self {
44        use wasm_bindgen::JsValue;
45        let r = ::js_sys::Reflect::set(
46            self.as_ref(),
47            &JsValue::from("useSecureTransport"),
48            &JsValue::from(val),
49        );
50        debug_assert!(
51            r.is_ok(),
52            "setting properties should never fail on our dictionary objects"
53        );
54        let _ = r;
55        self
56    }
57}
58impl Default for SocketOptions {
59    fn default() -> Self {
60        Self::new()
61    }
62}