1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
use super::*;
/// The Request class.
/// [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Request {
inner: Any,
}
impl FromVal for Request {
fn from_val(v: &Any) -> Self {
Request {
inner: Any::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for Request {
type Target = Any;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for Request {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for Request {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for Request {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<Request> for Any {
fn from(s: Request) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&Request> for Any {
fn from(s: &Request) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(Request);
impl Request {
/// Getter of the `method` attribute.
/// [`Request.method`](https://developer.mozilla.org/en-US/docs/Web/API/Request/method)
pub fn method(&self) -> JsString {
self.inner.get("method").as_::<JsString>()
}
}
impl Request {
/// Getter of the `url` attribute.
/// [`Request.url`](https://developer.mozilla.org/en-US/docs/Web/API/Request/url)
pub fn url(&self) -> JsString {
self.inner.get("url").as_::<JsString>()
}
}
impl Request {
/// Getter of the `headers` attribute.
/// [`Request.headers`](https://developer.mozilla.org/en-US/docs/Web/API/Request/headers)
pub fn headers(&self) -> Headers {
self.inner.get("headers").as_::<Headers>()
}
}
impl Request {
/// Getter of the `destination` attribute.
/// [`Request.destination`](https://developer.mozilla.org/en-US/docs/Web/API/Request/destination)
pub fn destination(&self) -> RequestDestination {
self.inner.get("destination").as_::<RequestDestination>()
}
}
impl Request {
/// Getter of the `referrer` attribute.
/// [`Request.referrer`](https://developer.mozilla.org/en-US/docs/Web/API/Request/referrer)
pub fn referrer(&self) -> JsString {
self.inner.get("referrer").as_::<JsString>()
}
}
impl Request {
/// Getter of the `referrerPolicy` attribute.
/// [`Request.referrerPolicy`](https://developer.mozilla.org/en-US/docs/Web/API/Request/referrerPolicy)
pub fn referrer_policy(&self) -> ReferrerPolicy {
self.inner.get("referrerPolicy").as_::<ReferrerPolicy>()
}
}
impl Request {
/// Getter of the `mode` attribute.
/// [`Request.mode`](https://developer.mozilla.org/en-US/docs/Web/API/Request/mode)
pub fn mode(&self) -> RequestMode {
self.inner.get("mode").as_::<RequestMode>()
}
}
impl Request {
/// Getter of the `credentials` attribute.
/// [`Request.credentials`](https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials)
pub fn credentials(&self) -> RequestCredentials {
self.inner.get("credentials").as_::<RequestCredentials>()
}
}
impl Request {
/// Getter of the `cache` attribute.
/// [`Request.cache`](https://developer.mozilla.org/en-US/docs/Web/API/Request/cache)
pub fn cache(&self) -> RequestCache {
self.inner.get("cache").as_::<RequestCache>()
}
}
impl Request {
/// Getter of the `redirect` attribute.
/// [`Request.redirect`](https://developer.mozilla.org/en-US/docs/Web/API/Request/redirect)
pub fn redirect(&self) -> RequestRedirect {
self.inner.get("redirect").as_::<RequestRedirect>()
}
}
impl Request {
/// Getter of the `integrity` attribute.
/// [`Request.integrity`](https://developer.mozilla.org/en-US/docs/Web/API/Request/integrity)
pub fn integrity(&self) -> JsString {
self.inner.get("integrity").as_::<JsString>()
}
}
impl Request {
/// Getter of the `keepalive` attribute.
/// [`Request.keepalive`](https://developer.mozilla.org/en-US/docs/Web/API/Request/keepalive)
pub fn keepalive(&self) -> bool {
self.inner.get("keepalive").as_::<bool>()
}
}
impl Request {
/// Getter of the `isReloadNavigation` attribute.
/// [`Request.isReloadNavigation`](https://developer.mozilla.org/en-US/docs/Web/API/Request/isReloadNavigation)
pub fn is_reload_navigation(&self) -> bool {
self.inner.get("isReloadNavigation").as_::<bool>()
}
}
impl Request {
/// Getter of the `isHistoryNavigation` attribute.
/// [`Request.isHistoryNavigation`](https://developer.mozilla.org/en-US/docs/Web/API/Request/isHistoryNavigation)
pub fn is_history_navigation(&self) -> bool {
self.inner.get("isHistoryNavigation").as_::<bool>()
}
}
impl Request {
/// Getter of the `signal` attribute.
/// [`Request.signal`](https://developer.mozilla.org/en-US/docs/Web/API/Request/signal)
pub fn signal(&self) -> AbortSignal {
self.inner.get("signal").as_::<AbortSignal>()
}
}
impl Request {
/// Getter of the `duplex` attribute.
/// [`Request.duplex`](https://developer.mozilla.org/en-US/docs/Web/API/Request/duplex)
pub fn duplex(&self) -> RequestDuplex {
self.inner.get("duplex").as_::<RequestDuplex>()
}
}
impl Request {
/// Getter of the `targetAddressSpace` attribute.
/// [`Request.targetAddressSpace`](https://developer.mozilla.org/en-US/docs/Web/API/Request/targetAddressSpace)
pub fn target_address_space(&self) -> IPAddressSpace {
self.inner.get("targetAddressSpace").as_::<IPAddressSpace>()
}
}
impl Request {
/// Getter of the `body` attribute.
/// [`Request.body`](https://developer.mozilla.org/en-US/docs/Web/API/Request/body)
pub fn body(&self) -> ReadableStream {
self.inner.get("body").as_::<ReadableStream>()
}
}
impl Request {
/// Getter of the `bodyUsed` attribute.
/// [`Request.bodyUsed`](https://developer.mozilla.org/en-US/docs/Web/API/Request/bodyUsed)
pub fn body_used(&self) -> bool {
self.inner.get("bodyUsed").as_::<bool>()
}
}
impl Request {
/// The `new Request(..)` constructor, creating a new Request instance
pub fn new(input: &Any) -> Request {
Self {
inner: Any::global("Request").new(&[input.into()]).as_::<Any>(),
}
}
}
impl Request {
/// The `new Request(..)` constructor, creating a new Request instance
pub fn new_with_init(input: &Any, init: &RequestInit) -> Request {
Self {
inner: Any::global("Request")
.new(&[input.into(), init.into()])
.as_::<Any>(),
}
}
}
impl Request {
/// The clone method.
/// [`Request.clone`](https://developer.mozilla.org/en-US/docs/Web/API/Request/clone)
pub fn clone_(&self) -> Request {
self.inner.call("clone", &[]).as_::<Request>()
}
}
impl Request {
/// The arrayBuffer method.
/// [`Request.arrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/API/Request/arrayBuffer)
pub fn array_buffer(&self) -> Promise<ArrayBuffer> {
self.inner
.call("arrayBuffer", &[])
.as_::<Promise<ArrayBuffer>>()
}
}
impl Request {
/// The blob method.
/// [`Request.blob`](https://developer.mozilla.org/en-US/docs/Web/API/Request/blob)
pub fn blob(&self) -> Promise<Blob> {
self.inner.call("blob", &[]).as_::<Promise<Blob>>()
}
}
impl Request {
/// The bytes method.
/// [`Request.bytes`](https://developer.mozilla.org/en-US/docs/Web/API/Request/bytes)
pub fn bytes(&self) -> Promise<Uint8Array> {
self.inner.call("bytes", &[]).as_::<Promise<Uint8Array>>()
}
}
impl Request {
/// The formData method.
/// [`Request.formData`](https://developer.mozilla.org/en-US/docs/Web/API/Request/formData)
pub fn form_data(&self) -> Promise<FormData> {
self.inner.call("formData", &[]).as_::<Promise<FormData>>()
}
}
impl Request {
/// The json method.
/// [`Request.json`](https://developer.mozilla.org/en-US/docs/Web/API/Request/json)
pub fn json(&self) -> Promise<Any> {
self.inner.call("json", &[]).as_::<Promise<Any>>()
}
}
impl Request {
/// The text method.
/// [`Request.text`](https://developer.mozilla.org/en-US/docs/Web/API/Request/text)
pub fn text(&self) -> Promise<JsString> {
self.inner.call("text", &[]).as_::<Promise<JsString>>()
}
}