1use crate::response_init::ResponseInit;
2use crate::FormData;
3
4use js_sys::Uint8Array;
5use wasm_bindgen::prelude::*;
6
7#[wasm_bindgen]
8extern "C" {
9 #[wasm_bindgen(extends=::js_sys::Object, js_name=Response)]
10 #[derive(Debug, Clone, PartialEq, Eq)]
11 pub type Response;
12
13 #[wasm_bindgen(structural, method, getter, js_class=Response, js_name=url)]
14 #[doc = "Getter for the `url` field of this object."]
15 pub fn url(this: &Response) -> String;
16
17 #[wasm_bindgen(structural, method, getter, js_class=Response, js_name=redirected)]
18 #[doc = "Getter for the `redirected` field of this object."]
19 pub fn redirected(this: &Response) -> bool;
20
21 #[wasm_bindgen(structural, method, getter, js_class=Response, js_name=status)]
22 #[doc = "Getter for the `status` field of this object."]
23 pub fn status(this: &Response) -> u16;
24
25 #[wasm_bindgen(structural, method, getter, js_class=Response, js_name=ok)]
26 #[doc = "Getter for the `ok` field of this object."]
27 pub fn ok(this: &Response) -> bool;
28
29 #[wasm_bindgen(structural, method, getter, js_class=Response, js_name=statusText)]
30 #[doc = "Getter for the `statusText` field of this object."]
31 pub fn status_text(this: &Response) -> String;
32
33 #[wasm_bindgen(structural, method, getter, js_class=Response, js_name=headers)]
34 #[doc = "Getter for the `headers` field of this object."]
35 pub fn headers(this: &Response) -> crate::headers::Headers;
36
37 #[wasm_bindgen(structural, method, getter, js_class=Response, js_name=webSocket)]
38 #[doc = "Getter for the `webSocket` field of this object."]
39 pub fn websocket(this: &Response) -> Option<crate::websocket::WebSocket>;
40
41 #[wasm_bindgen(structural, method, getter, js_class=Response, js_name=bodyUsed)]
42 #[doc = "Getter for the `bodyUsed` field of this object."]
43 pub fn body_used(this: &Response) -> bool;
44
45 #[wasm_bindgen(structural, method, getter, js_class=Response, js_name=body)]
46 #[doc = "Getter for the `body` field of this object."]
47 pub fn body(this: &Response) -> Option<web_sys::ReadableStream>;
48
49 #[wasm_bindgen(catch, constructor, js_class=Response)]
50 #[doc = "The `new Response(..)` constructor, creating a new instance of `Response`."]
51 pub fn new() -> Result<Response, JsValue>;
52
53 #[wasm_bindgen(catch, constructor, js_class=Response)]
54 #[doc = "The `new Response(..)` constructor, creating a new instance of `Response`."]
55 pub fn new_with_opt_u8_array(body: Option<Uint8Array>) -> Result<Response, JsValue>;
56
57 #[wasm_bindgen(catch, constructor, js_class=Response)]
58 #[doc = "The `new Response(..)` constructor, creating a new instance of `Response`."]
59 pub fn new_with_opt_form_data(body: Option<&FormData>) -> Result<Response, JsValue>;
60
61 #[wasm_bindgen(catch, constructor, js_class=Response)]
62 #[doc = "The `new Response(..)` constructor, creating a new instance of `Response`."]
63 pub fn new_with_opt_str(body: Option<&str>) -> Result<Response, JsValue>;
64
65 #[wasm_bindgen(catch, constructor, js_class=Response)]
66 #[doc = "The `new Response(..)` constructor, creating a new instance of `Response`."]
67 pub fn new_with_opt_stream(body: Option<&web_sys::ReadableStream>)
68 -> Result<Response, JsValue>;
69
70 #[wasm_bindgen(catch, constructor, js_class=Response)]
71 #[doc = "The `new Response(..)` constructor, creating a new instance of `Response`."]
72 pub fn new_with_opt_u8_array_and_init(
73 body: Option<Uint8Array>,
74 init: &ResponseInit,
75 ) -> Result<Response, JsValue>;
76
77 #[wasm_bindgen(catch, constructor, js_class=Response)]
78 #[doc = "The `new Response(..)` constructor, creating a new instance of `Response`."]
79 pub fn new_with_opt_form_data_and_init(
80 body: Option<&FormData>,
81 init: &ResponseInit,
82 ) -> Result<Response, JsValue>;
83
84 #[wasm_bindgen(catch, constructor, js_class=Response)]
85 #[doc = "The `new Response(..)` constructor, creating a new instance of `Response`."]
86 pub fn new_with_opt_str_and_init(
87 body: Option<&str>,
88 init: &ResponseInit,
89 ) -> Result<Response, JsValue>;
90
91 #[wasm_bindgen(catch, constructor, js_class=Response)]
92 #[doc = "The `new Response(..)` constructor, creating a new instance of `Response`."]
93 pub fn new_with_opt_stream_and_init(
94 body: Option<web_sys::ReadableStream>,
95 init: &ResponseInit,
96 ) -> Result<Response, JsValue>;
97
98 #[wasm_bindgen(catch, method, structural, js_class=Response, js_name=clone)]
99 #[doc = "The `clone()` method."]
100 pub fn clone(this: &Response) -> Result<Response, JsValue>;
101
102 #[wasm_bindgen(static_method_of=Response, js_class=Response, js_name=error)]
103 #[doc = "The `error()` method."]
104 pub fn error() -> Response;
105
106 #[wasm_bindgen(catch, static_method_of=Response, js_class=Response, js_name=redirect)]
107 #[doc = "The `redirect()` method."]
108 pub fn redirect(url: &str) -> Result<Response, JsValue>;
109
110 #[wasm_bindgen(catch, static_method_of=Response, js_class=Response, js_name=redirect)]
111 #[doc = "The `redirect()` method."]
112 pub fn redirect_with_status(url: &str, status: u16) -> Result<Response, JsValue>;
113
114 #[wasm_bindgen(catch, method, structural, js_class=Response, js_name=arrayBuffer)]
115 #[doc = "The `arrayBuffer()` method."]
116 pub fn array_buffer(this: &Response) -> Result<::js_sys::Promise, JsValue>;
117
118 #[wasm_bindgen(catch, method, structural, js_class=Response, js_name=blob)]
119 #[doc = "The `blob()` method."]
120 pub fn blob(this: &Response) -> Result<::js_sys::Promise, JsValue>;
121
122 #[wasm_bindgen(catch, method, structural, js_class=Response, js_name=formData)]
123 #[doc = "The `formData()` method."]
124 pub fn form_data(this: &Response) -> Result<::js_sys::Promise, JsValue>;
125
126 #[wasm_bindgen(catch, method, structural, js_class=Response, js_name=json)]
127 #[doc = "The `json()` method."]
128 pub fn json(this: &Response) -> Result<::js_sys::Promise, JsValue>;
129
130 #[wasm_bindgen(catch, method, structural, js_class=Response, js_name=text)]
131 #[doc = "The `text()` method."]
132 pub fn text(this: &Response) -> Result<::js_sys::Promise, JsValue>;
133}