1#![allow(unused_imports)]
2#![allow(clippy::all)]
3use super::*;
4use wasm_bindgen::prelude::*;
5#[wasm_bindgen]
6extern "C" {
7 # [wasm_bindgen (extends = :: js_sys :: Object , js_name = RequestInit)]
8 #[derive(Debug, Clone, PartialEq, Eq)]
9 #[doc = "The `RequestInit` dictionary."]
10 #[doc = ""]
11 #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
12 pub type RequestInit;
13}
14impl RequestInit {
15 #[doc = "Construct a new `RequestInit`."]
16 #[doc = ""]
17 #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
18 pub fn new() -> Self {
19 #[allow(unused_mut)]
20 let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
21 ret
22 }
23 #[doc = "Change the `body` field of this object."]
24 #[doc = ""]
25 #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
26 pub fn body(&mut self, val: Option<&::wasm_bindgen::JsValue>) -> &mut Self {
27 use wasm_bindgen::JsValue;
28 let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("body"), &JsValue::from(val));
29 debug_assert!(
30 r.is_ok(),
31 "setting properties should never fail on our dictionary objects"
32 );
33 let _ = r;
34 self
35 }
36 #[cfg(feature = "RequestCache")]
37 #[doc = "Change the `cache` field of this object."]
38 #[doc = ""]
39 #[doc = "*This API requires the following crate features to be activated: `RequestCache`, `RequestInit`*"]
40 pub fn cache(&mut self, val: RequestCache) -> &mut Self {
41 use wasm_bindgen::JsValue;
42 let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("cache"), &JsValue::from(val));
43 debug_assert!(
44 r.is_ok(),
45 "setting properties should never fail on our dictionary objects"
46 );
47 let _ = r;
48 self
49 }
50 #[cfg(feature = "RequestCredentials")]
51 #[doc = "Change the `credentials` field of this object."]
52 #[doc = ""]
53 #[doc = "*This API requires the following crate features to be activated: `RequestCredentials`, `RequestInit`*"]
54 pub fn credentials(&mut self, val: RequestCredentials) -> &mut Self {
55 use wasm_bindgen::JsValue;
56 let r = ::js_sys::Reflect::set(
57 self.as_ref(),
58 &JsValue::from("credentials"),
59 &JsValue::from(val),
60 );
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 #[doc = "Change the `headers` field of this object."]
69 #[doc = ""]
70 #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
71 pub fn headers(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
72 use wasm_bindgen::JsValue;
73 let r = ::js_sys::Reflect::set(
74 self.as_ref(),
75 &JsValue::from("headers"),
76 &JsValue::from(val),
77 );
78 debug_assert!(
79 r.is_ok(),
80 "setting properties should never fail on our dictionary objects"
81 );
82 let _ = r;
83 self
84 }
85 #[doc = "Change the `integrity` field of this object."]
86 #[doc = ""]
87 #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
88 pub fn integrity(&mut self, val: &str) -> &mut Self {
89 use wasm_bindgen::JsValue;
90 let r = ::js_sys::Reflect::set(
91 self.as_ref(),
92 &JsValue::from("integrity"),
93 &JsValue::from(val),
94 );
95 debug_assert!(
96 r.is_ok(),
97 "setting properties should never fail on our dictionary objects"
98 );
99 let _ = r;
100 self
101 }
102 #[doc = "Change the `method` field of this object."]
103 #[doc = ""]
104 #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
105 pub fn method(&mut self, val: &str) -> &mut Self {
106 use wasm_bindgen::JsValue;
107 let r =
108 ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("method"), &JsValue::from(val));
109 debug_assert!(
110 r.is_ok(),
111 "setting properties should never fail on our dictionary objects"
112 );
113 let _ = r;
114 self
115 }
116 #[cfg(feature = "RequestMode")]
117 #[doc = "Change the `mode` field of this object."]
118 #[doc = ""]
119 #[doc = "*This API requires the following crate features to be activated: `RequestInit`, `RequestMode`*"]
120 pub fn mode(&mut self, val: RequestMode) -> &mut Self {
121 use wasm_bindgen::JsValue;
122 let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("mode"), &JsValue::from(val));
123 debug_assert!(
124 r.is_ok(),
125 "setting properties should never fail on our dictionary objects"
126 );
127 let _ = r;
128 self
129 }
130 #[cfg(feature = "ObserverCallback")]
131 #[doc = "Change the `observe` field of this object."]
132 #[doc = ""]
133 #[doc = "*This API requires the following crate features to be activated: `ObserverCallback`, `RequestInit`*"]
134 pub fn observe(&mut self, val: &ObserverCallback) -> &mut Self {
135 use wasm_bindgen::JsValue;
136 let r = ::js_sys::Reflect::set(
137 self.as_ref(),
138 &JsValue::from("observe"),
139 &JsValue::from(val),
140 );
141 debug_assert!(
142 r.is_ok(),
143 "setting properties should never fail on our dictionary objects"
144 );
145 let _ = r;
146 self
147 }
148 #[cfg(feature = "RequestRedirect")]
149 #[doc = "Change the `redirect` field of this object."]
150 #[doc = ""]
151 #[doc = "*This API requires the following crate features to be activated: `RequestInit`, `RequestRedirect`*"]
152 pub fn redirect(&mut self, val: RequestRedirect) -> &mut Self {
153 use wasm_bindgen::JsValue;
154 let r = ::js_sys::Reflect::set(
155 self.as_ref(),
156 &JsValue::from("redirect"),
157 &JsValue::from(val),
158 );
159 debug_assert!(
160 r.is_ok(),
161 "setting properties should never fail on our dictionary objects"
162 );
163 let _ = r;
164 self
165 }
166 #[doc = "Change the `referrer` field of this object."]
167 #[doc = ""]
168 #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
169 pub fn referrer(&mut self, val: &str) -> &mut Self {
170 use wasm_bindgen::JsValue;
171 let r = ::js_sys::Reflect::set(
172 self.as_ref(),
173 &JsValue::from("referrer"),
174 &JsValue::from(val),
175 );
176 debug_assert!(
177 r.is_ok(),
178 "setting properties should never fail on our dictionary objects"
179 );
180 let _ = r;
181 self
182 }
183 #[cfg(feature = "ReferrerPolicy")]
184 #[doc = "Change the `referrerPolicy` field of this object."]
185 #[doc = ""]
186 #[doc = "*This API requires the following crate features to be activated: `ReferrerPolicy`, `RequestInit`*"]
187 pub fn referrer_policy(&mut self, val: ReferrerPolicy) -> &mut Self {
188 use wasm_bindgen::JsValue;
189 let r = ::js_sys::Reflect::set(
190 self.as_ref(),
191 &JsValue::from("referrerPolicy"),
192 &JsValue::from(val),
193 );
194 debug_assert!(
195 r.is_ok(),
196 "setting properties should never fail on our dictionary objects"
197 );
198 let _ = r;
199 self
200 }
201 #[cfg(feature = "AbortSignal")]
202 #[doc = "Change the `signal` field of this object."]
203 #[doc = ""]
204 #[doc = "*This API requires the following crate features to be activated: `AbortSignal`, `RequestInit`*"]
205 pub fn signal(&mut self, val: Option<&AbortSignal>) -> &mut Self {
206 use wasm_bindgen::JsValue;
207 let r =
208 ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("signal"), &JsValue::from(val));
209 debug_assert!(
210 r.is_ok(),
211 "setting properties should never fail on our dictionary objects"
212 );
213 let _ = r;
214 self
215 }
216}
217impl Default for RequestInit {
218 fn default() -> Self {
219 Self::new()
220 }
221}
222