worker_plus_sys/
response_init.rs1use crate::websocket::WebSocket;
2use wasm_bindgen::prelude::*;
3
4#[wasm_bindgen]
5extern "C" {
6 #[wasm_bindgen(extends = js_sys::Object , js_name = ResponseInit)]
7 #[derive(Debug, Clone, PartialEq, Eq)]
8 #[doc = "The `ResponseInit` dictionary."]
9 pub type ResponseInit;
10}
11impl ResponseInit {
12 #[doc = "Construct a new `ResponseInit`."]
13 pub fn new() -> Self {
14 ::wasm_bindgen::JsCast::unchecked_into(js_sys::Object::new())
15 }
16
17 #[doc = "Change the `headers` field of this object."]
18 pub fn headers(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
19 let r = js_sys::Reflect::set(
20 self.as_ref(),
21 &JsValue::from("headers"),
22 &JsValue::from(val),
23 );
24 debug_assert!(
25 r.is_ok(),
26 "setting properties should never fail on our dictionary objects"
27 );
28 let _ = r;
29 self
30 }
31
32 #[doc = "Change the `status` field of this object."]
33 pub fn status(&mut self, val: u16) -> &mut Self {
34 let r = js_sys::Reflect::set(self.as_ref(), &JsValue::from("status"), &JsValue::from(val));
35 debug_assert!(
36 r.is_ok(),
37 "setting properties should never fail on our dictionary objects"
38 );
39 let _ = r;
40 self
41 }
42
43 #[doc = "Change the `statusText` field of this object."]
44 pub fn status_text(&mut self, val: &str) -> &mut Self {
45 let r = js_sys::Reflect::set(
46 self.as_ref(),
47 &JsValue::from("statusText"),
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
58 #[doc = "Change the `webSocket` field of this object."]
59 pub fn websocket(&mut self, val: &WebSocket) -> &mut Self {
60 let r = js_sys::Reflect::set(self.as_ref(), &JsValue::from("webSocket"), val.as_ref());
61 debug_assert!(
62 r.is_ok(),
63 "setting properties should never fail on our dictionary objects"
64 );
65 let _ = r;
66 self
67 }
68}
69impl Default for ResponseInit {
70 fn default() -> Self {
71 Self::new()
72 }
73}