web_sys/features/
gen_WebSocket.rs

1#![allow(unused_imports)]
2#![allow(clippy::all)]
3use super::*;
4use wasm_bindgen::prelude::*;
5#[wasm_bindgen]
6extern "C" {
7    # [wasm_bindgen (extends = EventTarget , extends = :: js_sys :: Object , js_name = WebSocket , typescript_type = "WebSocket")]
8    #[derive(Debug, Clone, PartialEq, Eq)]
9    #[doc = "The `WebSocket` class."]
10    #[doc = ""]
11    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)"]
12    #[doc = ""]
13    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
14    pub type WebSocket;
15    # [wasm_bindgen (structural , method , getter , js_class = "WebSocket" , js_name = url)]
16    #[doc = "Getter for the `url` field of this object."]
17    #[doc = ""]
18    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/url)"]
19    #[doc = ""]
20    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
21    pub fn url(this: &WebSocket) -> ::alloc::string::String;
22    # [wasm_bindgen (structural , method , getter , js_class = "WebSocket" , js_name = readyState)]
23    #[doc = "Getter for the `readyState` field of this object."]
24    #[doc = ""]
25    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/readyState)"]
26    #[doc = ""]
27    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
28    pub fn ready_state(this: &WebSocket) -> u16;
29    # [wasm_bindgen (structural , method , getter , js_class = "WebSocket" , js_name = bufferedAmount)]
30    #[doc = "Getter for the `bufferedAmount` field of this object."]
31    #[doc = ""]
32    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/bufferedAmount)"]
33    #[doc = ""]
34    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
35    pub fn buffered_amount(this: &WebSocket) -> u32;
36    # [wasm_bindgen (structural , method , getter , js_class = "WebSocket" , js_name = onopen)]
37    #[doc = "Getter for the `onopen` field of this object."]
38    #[doc = ""]
39    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/onopen)"]
40    #[doc = ""]
41    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
42    pub fn onopen(this: &WebSocket) -> Option<::js_sys::Function>;
43    # [wasm_bindgen (structural , method , setter , js_class = "WebSocket" , js_name = onopen)]
44    #[doc = "Setter for the `onopen` field of this object."]
45    #[doc = ""]
46    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/onopen)"]
47    #[doc = ""]
48    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
49    pub fn set_onopen(this: &WebSocket, value: Option<&::js_sys::Function>);
50    # [wasm_bindgen (structural , method , getter , js_class = "WebSocket" , js_name = onerror)]
51    #[doc = "Getter for the `onerror` field of this object."]
52    #[doc = ""]
53    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/onerror)"]
54    #[doc = ""]
55    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
56    pub fn onerror(this: &WebSocket) -> Option<::js_sys::Function>;
57    # [wasm_bindgen (structural , method , setter , js_class = "WebSocket" , js_name = onerror)]
58    #[doc = "Setter for the `onerror` field of this object."]
59    #[doc = ""]
60    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/onerror)"]
61    #[doc = ""]
62    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
63    pub fn set_onerror(this: &WebSocket, value: Option<&::js_sys::Function>);
64    # [wasm_bindgen (structural , method , getter , js_class = "WebSocket" , js_name = onclose)]
65    #[doc = "Getter for the `onclose` field of this object."]
66    #[doc = ""]
67    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/onclose)"]
68    #[doc = ""]
69    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
70    pub fn onclose(this: &WebSocket) -> Option<::js_sys::Function>;
71    # [wasm_bindgen (structural , method , setter , js_class = "WebSocket" , js_name = onclose)]
72    #[doc = "Setter for the `onclose` field of this object."]
73    #[doc = ""]
74    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/onclose)"]
75    #[doc = ""]
76    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
77    pub fn set_onclose(this: &WebSocket, value: Option<&::js_sys::Function>);
78    # [wasm_bindgen (structural , method , getter , js_class = "WebSocket" , js_name = extensions)]
79    #[doc = "Getter for the `extensions` field of this object."]
80    #[doc = ""]
81    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/extensions)"]
82    #[doc = ""]
83    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
84    pub fn extensions(this: &WebSocket) -> ::alloc::string::String;
85    # [wasm_bindgen (structural , method , getter , js_class = "WebSocket" , js_name = protocol)]
86    #[doc = "Getter for the `protocol` field of this object."]
87    #[doc = ""]
88    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/protocol)"]
89    #[doc = ""]
90    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
91    pub fn protocol(this: &WebSocket) -> ::alloc::string::String;
92    # [wasm_bindgen (structural , method , getter , js_class = "WebSocket" , js_name = onmessage)]
93    #[doc = "Getter for the `onmessage` field of this object."]
94    #[doc = ""]
95    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/onmessage)"]
96    #[doc = ""]
97    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
98    pub fn onmessage(this: &WebSocket) -> Option<::js_sys::Function>;
99    # [wasm_bindgen (structural , method , setter , js_class = "WebSocket" , js_name = onmessage)]
100    #[doc = "Setter for the `onmessage` field of this object."]
101    #[doc = ""]
102    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/onmessage)"]
103    #[doc = ""]
104    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
105    pub fn set_onmessage(this: &WebSocket, value: Option<&::js_sys::Function>);
106    #[cfg(feature = "BinaryType")]
107    # [wasm_bindgen (structural , method , getter , js_class = "WebSocket" , js_name = binaryType)]
108    #[doc = "Getter for the `binaryType` field of this object."]
109    #[doc = ""]
110    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/binaryType)"]
111    #[doc = ""]
112    #[doc = "*This API requires the following crate features to be activated: `BinaryType`, `WebSocket`*"]
113    pub fn binary_type(this: &WebSocket) -> BinaryType;
114    #[cfg(feature = "BinaryType")]
115    # [wasm_bindgen (structural , method , setter , js_class = "WebSocket" , js_name = binaryType)]
116    #[doc = "Setter for the `binaryType` field of this object."]
117    #[doc = ""]
118    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/binaryType)"]
119    #[doc = ""]
120    #[doc = "*This API requires the following crate features to be activated: `BinaryType`, `WebSocket`*"]
121    pub fn set_binary_type(this: &WebSocket, value: BinaryType);
122    #[wasm_bindgen(catch, constructor, js_class = "WebSocket")]
123    #[doc = "The `new WebSocket(..)` constructor, creating a new instance of `WebSocket`."]
124    #[doc = ""]
125    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket)"]
126    #[doc = ""]
127    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
128    pub fn new(url: &str) -> Result<WebSocket, JsValue>;
129    #[wasm_bindgen(catch, constructor, js_class = "WebSocket")]
130    #[doc = "The `new WebSocket(..)` constructor, creating a new instance of `WebSocket`."]
131    #[doc = ""]
132    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket)"]
133    #[doc = ""]
134    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
135    pub fn new_with_str(url: &str, protocols: &str) -> Result<WebSocket, JsValue>;
136    #[wasm_bindgen(catch, constructor, js_class = "WebSocket")]
137    #[doc = "The `new WebSocket(..)` constructor, creating a new instance of `WebSocket`."]
138    #[doc = ""]
139    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket)"]
140    #[doc = ""]
141    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
142    pub fn new_with_str_sequence(
143        url: &str,
144        protocols: &::wasm_bindgen::JsValue,
145    ) -> Result<WebSocket, JsValue>;
146    # [wasm_bindgen (catch , method , structural , js_class = "WebSocket" , js_name = close)]
147    #[doc = "The `close()` method."]
148    #[doc = ""]
149    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close)"]
150    #[doc = ""]
151    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
152    pub fn close(this: &WebSocket) -> Result<(), JsValue>;
153    # [wasm_bindgen (catch , method , structural , js_class = "WebSocket" , js_name = close)]
154    #[doc = "The `close()` method."]
155    #[doc = ""]
156    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close)"]
157    #[doc = ""]
158    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
159    pub fn close_with_code(this: &WebSocket, code: u16) -> Result<(), JsValue>;
160    # [wasm_bindgen (catch , method , structural , js_class = "WebSocket" , js_name = close)]
161    #[doc = "The `close()` method."]
162    #[doc = ""]
163    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close)"]
164    #[doc = ""]
165    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
166    pub fn close_with_code_and_reason(
167        this: &WebSocket,
168        code: u16,
169        reason: &str,
170    ) -> Result<(), JsValue>;
171    # [wasm_bindgen (catch , method , structural , js_class = "WebSocket" , js_name = send)]
172    #[doc = "The `send()` method."]
173    #[doc = ""]
174    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send)"]
175    #[doc = ""]
176    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
177    pub fn send_with_str(this: &WebSocket, data: &str) -> Result<(), JsValue>;
178    #[cfg(feature = "Blob")]
179    # [wasm_bindgen (catch , method , structural , js_class = "WebSocket" , js_name = send)]
180    #[doc = "The `send()` method."]
181    #[doc = ""]
182    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send)"]
183    #[doc = ""]
184    #[doc = "*This API requires the following crate features to be activated: `Blob`, `WebSocket`*"]
185    pub fn send_with_blob(this: &WebSocket, data: &Blob) -> Result<(), JsValue>;
186    # [wasm_bindgen (catch , method , structural , js_class = "WebSocket" , js_name = send)]
187    #[doc = "The `send()` method."]
188    #[doc = ""]
189    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send)"]
190    #[doc = ""]
191    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
192    pub fn send_with_array_buffer(
193        this: &WebSocket,
194        data: &::js_sys::ArrayBuffer,
195    ) -> Result<(), JsValue>;
196    # [wasm_bindgen (catch , method , structural , js_class = "WebSocket" , js_name = send)]
197    #[doc = "The `send()` method."]
198    #[doc = ""]
199    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send)"]
200    #[doc = ""]
201    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
202    pub fn send_with_array_buffer_view(
203        this: &WebSocket,
204        data: &::js_sys::Object,
205    ) -> Result<(), JsValue>;
206    # [wasm_bindgen (catch , method , structural , js_class = "WebSocket" , js_name = send)]
207    #[doc = "The `send()` method."]
208    #[doc = ""]
209    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send)"]
210    #[doc = ""]
211    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
212    pub fn send_with_u8_array(this: &WebSocket, data: &[u8]) -> Result<(), JsValue>;
213    # [wasm_bindgen (catch , method , structural , js_class = "WebSocket" , js_name = send)]
214    #[doc = "The `send()` method."]
215    #[doc = ""]
216    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send)"]
217    #[doc = ""]
218    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
219    pub fn send_with_js_u8_array(
220        this: &WebSocket,
221        data: &::js_sys::Uint8Array,
222    ) -> Result<(), JsValue>;
223}
224impl WebSocket {
225    #[doc = "The `WebSocket.CONNECTING` const."]
226    #[doc = ""]
227    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
228    pub const CONNECTING: u16 = 0i64 as u16;
229    #[doc = "The `WebSocket.OPEN` const."]
230    #[doc = ""]
231    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
232    pub const OPEN: u16 = 1u64 as u16;
233    #[doc = "The `WebSocket.CLOSING` const."]
234    #[doc = ""]
235    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
236    pub const CLOSING: u16 = 2u64 as u16;
237    #[doc = "The `WebSocket.CLOSED` const."]
238    #[doc = ""]
239    #[doc = "*This API requires the following crate features to be activated: `WebSocket`*"]
240    pub const CLOSED: u16 = 3u64 as u16;
241}