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