Skip to main content

web_sys/features/
gen_RequestInit.rs

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    #[doc = "Get the `body` field of this object."]
14    #[doc = ""]
15    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
16    #[wasm_bindgen(method, getter = "body")]
17    pub fn get_body(this: &RequestInit) -> ::wasm_bindgen::JsValue;
18    #[doc = "Change the `body` field of this object."]
19    #[doc = ""]
20    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
21    #[wasm_bindgen(method, setter = "body")]
22    pub fn set_body(this: &RequestInit, val: &::wasm_bindgen::JsValue);
23    #[cfg(feature = "Blob")]
24    #[doc = "Change the `body` field of this object."]
25    #[doc = ""]
26    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
27    #[wasm_bindgen(method, setter = "body")]
28    pub fn set_body_opt_blob(this: &RequestInit, val: Option<&Blob>);
29    #[doc = "Change the `body` field of this object."]
30    #[doc = ""]
31    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
32    #[wasm_bindgen(method, setter = "body")]
33    pub fn set_body_opt_buffer_source(this: &RequestInit, val: Option<&::js_sys::Object>);
34    #[doc = "Change the `body` field of this object."]
35    #[doc = ""]
36    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
37    #[wasm_bindgen(method, setter = "body")]
38    pub fn set_body_opt_u8_slice(this: &RequestInit, val: Option<&mut [u8]>);
39    #[doc = "Change the `body` field of this object."]
40    #[doc = ""]
41    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
42    #[wasm_bindgen(method, setter = "body")]
43    pub fn set_body_opt_u8_array(this: &RequestInit, val: Option<&::js_sys::Uint8Array>);
44    #[cfg(feature = "FormData")]
45    #[doc = "Change the `body` field of this object."]
46    #[doc = ""]
47    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
48    #[wasm_bindgen(method, setter = "body")]
49    pub fn set_body_opt_form_data(this: &RequestInit, val: Option<&FormData>);
50    #[cfg(feature = "UrlSearchParams")]
51    #[doc = "Change the `body` field of this object."]
52    #[doc = ""]
53    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
54    #[wasm_bindgen(method, setter = "body")]
55    pub fn set_body_opt_url_search_params(this: &RequestInit, val: Option<&UrlSearchParams>);
56    #[doc = "Change the `body` field of this object."]
57    #[doc = ""]
58    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
59    #[wasm_bindgen(method, setter = "body")]
60    pub fn set_body_opt_str(this: &RequestInit, val: Option<&str>);
61    #[cfg(feature = "ReadableStream")]
62    #[doc = "Change the `body` field of this object."]
63    #[doc = ""]
64    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
65    #[wasm_bindgen(method, setter = "body")]
66    pub fn set_body_opt_readable_stream(this: &RequestInit, val: Option<&ReadableStream>);
67    #[cfg(feature = "RequestCache")]
68    #[doc = "Get the `cache` field of this object."]
69    #[doc = ""]
70    #[doc = "*This API requires the following crate features to be activated: `RequestCache`, `RequestInit`*"]
71    #[wasm_bindgen(method, getter = "cache")]
72    pub fn get_cache(this: &RequestInit) -> Option<RequestCache>;
73    #[cfg(feature = "RequestCache")]
74    #[doc = "Change the `cache` field of this object."]
75    #[doc = ""]
76    #[doc = "*This API requires the following crate features to be activated: `RequestCache`, `RequestInit`*"]
77    #[wasm_bindgen(method, setter = "cache")]
78    pub fn set_cache(this: &RequestInit, val: RequestCache);
79    #[cfg(feature = "RequestCredentials")]
80    #[doc = "Get the `credentials` field of this object."]
81    #[doc = ""]
82    #[doc = "*This API requires the following crate features to be activated: `RequestCredentials`, `RequestInit`*"]
83    #[wasm_bindgen(method, getter = "credentials")]
84    pub fn get_credentials(this: &RequestInit) -> Option<RequestCredentials>;
85    #[cfg(feature = "RequestCredentials")]
86    #[doc = "Change the `credentials` field of this object."]
87    #[doc = ""]
88    #[doc = "*This API requires the following crate features to be activated: `RequestCredentials`, `RequestInit`*"]
89    #[wasm_bindgen(method, setter = "credentials")]
90    pub fn set_credentials(this: &RequestInit, val: RequestCredentials);
91    #[doc = "Get the `headers` field of this object."]
92    #[doc = ""]
93    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
94    #[wasm_bindgen(method, getter = "headers")]
95    pub fn get_headers(this: &RequestInit) -> ::wasm_bindgen::JsValue;
96    #[doc = "Change the `headers` field of this object."]
97    #[doc = ""]
98    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
99    #[wasm_bindgen(method, setter = "headers")]
100    pub fn set_headers(this: &RequestInit, val: &::wasm_bindgen::JsValue);
101    #[cfg(feature = "Headers")]
102    #[doc = "Change the `headers` field of this object."]
103    #[doc = ""]
104    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
105    #[wasm_bindgen(method, setter = "headers")]
106    pub fn set_headers_headers(this: &RequestInit, val: &Headers);
107    #[doc = "Change the `headers` field of this object."]
108    #[doc = ""]
109    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
110    #[wasm_bindgen(method, setter = "headers")]
111    pub fn set_headers_str_sequence_sequence(this: &RequestInit, val: &::wasm_bindgen::JsValue);
112    #[doc = "Change the `headers` field of this object."]
113    #[doc = ""]
114    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
115    #[wasm_bindgen(method, setter = "headers")]
116    pub fn set_headers_record_from_str_to_str(this: &RequestInit, val: &::js_sys::Object);
117    #[doc = "Get the `integrity` field of this object."]
118    #[doc = ""]
119    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
120    #[wasm_bindgen(method, getter = "integrity")]
121    pub fn get_integrity(this: &RequestInit) -> Option<::alloc::string::String>;
122    #[doc = "Change the `integrity` field of this object."]
123    #[doc = ""]
124    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
125    #[wasm_bindgen(method, setter = "integrity")]
126    pub fn set_integrity(this: &RequestInit, val: &str);
127    #[doc = "Get the `method` field of this object."]
128    #[doc = ""]
129    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
130    #[wasm_bindgen(method, getter = "method")]
131    pub fn get_method(this: &RequestInit) -> Option<::alloc::string::String>;
132    #[doc = "Change the `method` field of this object."]
133    #[doc = ""]
134    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
135    #[wasm_bindgen(method, setter = "method")]
136    pub fn set_method(this: &RequestInit, val: &str);
137    #[cfg(feature = "RequestMode")]
138    #[doc = "Get the `mode` field of this object."]
139    #[doc = ""]
140    #[doc = "*This API requires the following crate features to be activated: `RequestInit`, `RequestMode`*"]
141    #[wasm_bindgen(method, getter = "mode")]
142    pub fn get_mode(this: &RequestInit) -> Option<RequestMode>;
143    #[cfg(feature = "RequestMode")]
144    #[doc = "Change the `mode` field of this object."]
145    #[doc = ""]
146    #[doc = "*This API requires the following crate features to be activated: `RequestInit`, `RequestMode`*"]
147    #[wasm_bindgen(method, setter = "mode")]
148    pub fn set_mode(this: &RequestInit, val: RequestMode);
149    #[cfg(feature = "ObserverCallback")]
150    #[doc = "Get the `observe` field of this object."]
151    #[doc = ""]
152    #[doc = "*This API requires the following crate features to be activated: `ObserverCallback`, `RequestInit`*"]
153    #[wasm_bindgen(method, getter = "observe")]
154    pub fn get_observe(this: &RequestInit) -> Option<ObserverCallback>;
155    #[cfg(feature = "ObserverCallback")]
156    #[doc = "Change the `observe` field of this object."]
157    #[doc = ""]
158    #[doc = "*This API requires the following crate features to be activated: `ObserverCallback`, `RequestInit`*"]
159    #[wasm_bindgen(method, setter = "observe")]
160    pub fn set_observe(this: &RequestInit, val: &ObserverCallback);
161    #[doc = "Change the `observe` field of this object."]
162    #[doc = ""]
163    #[doc = "*This API requires the following crate features to be activated: `ObserverCallback`, `RequestInit`*"]
164    #[wasm_bindgen(method, setter = "observe")]
165    pub fn set_observe_callback(this: &RequestInit, val: &::js_sys::Function);
166    #[cfg(feature = "ObserverCallback")]
167    #[doc = "Change the `observe` field of this object."]
168    #[doc = ""]
169    #[doc = "*This API requires the following crate features to be activated: `ObserverCallback`, `RequestInit`*"]
170    #[wasm_bindgen(method, setter = "observe")]
171    pub fn set_observe_observer_callback(this: &RequestInit, val: &ObserverCallback);
172    #[cfg(feature = "RequestRedirect")]
173    #[doc = "Get the `redirect` field of this object."]
174    #[doc = ""]
175    #[doc = "*This API requires the following crate features to be activated: `RequestInit`, `RequestRedirect`*"]
176    #[wasm_bindgen(method, getter = "redirect")]
177    pub fn get_redirect(this: &RequestInit) -> Option<RequestRedirect>;
178    #[cfg(feature = "RequestRedirect")]
179    #[doc = "Change the `redirect` field of this object."]
180    #[doc = ""]
181    #[doc = "*This API requires the following crate features to be activated: `RequestInit`, `RequestRedirect`*"]
182    #[wasm_bindgen(method, setter = "redirect")]
183    pub fn set_redirect(this: &RequestInit, val: RequestRedirect);
184    #[doc = "Get the `referrer` field of this object."]
185    #[doc = ""]
186    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
187    #[wasm_bindgen(method, getter = "referrer")]
188    pub fn get_referrer(this: &RequestInit) -> Option<::alloc::string::String>;
189    #[doc = "Change the `referrer` field of this object."]
190    #[doc = ""]
191    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
192    #[wasm_bindgen(method, setter = "referrer")]
193    pub fn set_referrer(this: &RequestInit, val: &str);
194    #[cfg(feature = "ReferrerPolicy")]
195    #[doc = "Get the `referrerPolicy` field of this object."]
196    #[doc = ""]
197    #[doc = "*This API requires the following crate features to be activated: `ReferrerPolicy`, `RequestInit`*"]
198    #[wasm_bindgen(method, getter = "referrerPolicy")]
199    pub fn get_referrer_policy(this: &RequestInit) -> Option<ReferrerPolicy>;
200    #[cfg(feature = "ReferrerPolicy")]
201    #[doc = "Change the `referrerPolicy` field of this object."]
202    #[doc = ""]
203    #[doc = "*This API requires the following crate features to be activated: `ReferrerPolicy`, `RequestInit`*"]
204    #[wasm_bindgen(method, setter = "referrerPolicy")]
205    pub fn set_referrer_policy(this: &RequestInit, val: ReferrerPolicy);
206    #[cfg(feature = "AbortSignal")]
207    #[doc = "Get the `signal` field of this object."]
208    #[doc = ""]
209    #[doc = "*This API requires the following crate features to be activated: `AbortSignal`, `RequestInit`*"]
210    #[wasm_bindgen(method, getter = "signal")]
211    pub fn get_signal(this: &RequestInit) -> Option<AbortSignal>;
212    #[cfg(feature = "AbortSignal")]
213    #[doc = "Change the `signal` field of this object."]
214    #[doc = ""]
215    #[doc = "*This API requires the following crate features to be activated: `AbortSignal`, `RequestInit`*"]
216    #[wasm_bindgen(method, setter = "signal")]
217    pub fn set_signal(this: &RequestInit, val: Option<&AbortSignal>);
218}
219impl RequestInit {
220    #[doc = "Construct a new `RequestInit`."]
221    #[doc = ""]
222    #[doc = "*This API requires the following crate features to be activated: `RequestInit`*"]
223    pub fn new() -> Self {
224        #[allow(unused_mut)]
225        let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
226        ret
227    }
228    #[deprecated = "Use `set_body()` instead."]
229    pub fn body(&mut self, val: Option<&::wasm_bindgen::JsValue>) -> &mut Self {
230        self.set_body(val.unwrap_or(&::wasm_bindgen::JsValue::NULL));
231        self
232    }
233    #[cfg(feature = "RequestCache")]
234    #[deprecated = "Use `set_cache()` instead."]
235    pub fn cache(&mut self, val: RequestCache) -> &mut Self {
236        self.set_cache(val);
237        self
238    }
239    #[cfg(feature = "RequestCredentials")]
240    #[deprecated = "Use `set_credentials()` instead."]
241    pub fn credentials(&mut self, val: RequestCredentials) -> &mut Self {
242        self.set_credentials(val);
243        self
244    }
245    #[deprecated = "Use `set_headers()` instead."]
246    pub fn headers(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
247        self.set_headers(val);
248        self
249    }
250    #[deprecated = "Use `set_integrity()` instead."]
251    pub fn integrity(&mut self, val: &str) -> &mut Self {
252        self.set_integrity(val);
253        self
254    }
255    #[deprecated = "Use `set_method()` instead."]
256    pub fn method(&mut self, val: &str) -> &mut Self {
257        self.set_method(val);
258        self
259    }
260    #[cfg(feature = "RequestMode")]
261    #[deprecated = "Use `set_mode()` instead."]
262    pub fn mode(&mut self, val: RequestMode) -> &mut Self {
263        self.set_mode(val);
264        self
265    }
266    #[cfg(feature = "ObserverCallback")]
267    #[deprecated = "Use `set_observe()` instead."]
268    pub fn observe(&mut self, val: &ObserverCallback) -> &mut Self {
269        self.set_observe(val);
270        self
271    }
272    #[cfg(feature = "RequestRedirect")]
273    #[deprecated = "Use `set_redirect()` instead."]
274    pub fn redirect(&mut self, val: RequestRedirect) -> &mut Self {
275        self.set_redirect(val);
276        self
277    }
278    #[deprecated = "Use `set_referrer()` instead."]
279    pub fn referrer(&mut self, val: &str) -> &mut Self {
280        self.set_referrer(val);
281        self
282    }
283    #[cfg(feature = "ReferrerPolicy")]
284    #[deprecated = "Use `set_referrer_policy()` instead."]
285    pub fn referrer_policy(&mut self, val: ReferrerPolicy) -> &mut Self {
286        self.set_referrer_policy(val);
287        self
288    }
289    #[cfg(feature = "AbortSignal")]
290    #[deprecated = "Use `set_signal()` instead."]
291    pub fn signal(&mut self, val: Option<&AbortSignal>) -> &mut Self {
292        self.set_signal(val);
293        self
294    }
295}
296impl Default for RequestInit {
297    fn default() -> Self {
298        Self::new()
299    }
300}