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