Skip to main content

web_sys/features/
gen_EventSource.rs

1#![allow(unused_imports)]
2#![allow(clippy::all)]
3use super::*;
4use wasm_bindgen::prelude::*;
5#[wasm_bindgen]
6extern "C" {
7    #[wasm_bindgen(
8        extends = "EventTarget",
9        extends = "::js_sys::Object",
10        js_name = "EventSource",
11        typescript_type = "EventSource"
12    )]
13    #[derive(Debug, Clone, PartialEq, Eq)]
14    #[doc = "The `EventSource` class."]
15    #[doc = ""]
16    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource)"]
17    #[doc = ""]
18    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
19    pub type EventSource;
20    #[wasm_bindgen(method, getter, js_class = "EventSource", js_name = "url")]
21    #[doc = "Getter for the `url` field of this object."]
22    #[doc = ""]
23    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/url)"]
24    #[doc = ""]
25    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
26    pub fn url(this: &EventSource) -> ::alloc::string::String;
27    #[wasm_bindgen(method, getter, js_class = "EventSource", js_name = "withCredentials")]
28    #[doc = "Getter for the `withCredentials` field of this object."]
29    #[doc = ""]
30    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/withCredentials)"]
31    #[doc = ""]
32    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
33    pub fn with_credentials(this: &EventSource) -> bool;
34    #[wasm_bindgen(method, getter, js_class = "EventSource", js_name = "readyState")]
35    #[doc = "Getter for the `readyState` field of this object."]
36    #[doc = ""]
37    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/readyState)"]
38    #[doc = ""]
39    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
40    pub fn ready_state(this: &EventSource) -> u16;
41    #[wasm_bindgen(method, getter, js_class = "EventSource", js_name = "onopen")]
42    #[doc = "Getter for the `onopen` field of this object."]
43    #[doc = ""]
44    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/onopen)"]
45    #[doc = ""]
46    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
47    pub fn onopen(this: &EventSource) -> Option<::js_sys::Function>;
48    #[wasm_bindgen(method, setter, js_class = "EventSource", js_name = "onopen")]
49    #[doc = "Setter for the `onopen` field of this object."]
50    #[doc = ""]
51    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/onopen)"]
52    #[doc = ""]
53    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
54    pub fn set_onopen(this: &EventSource, value: Option<&::js_sys::Function>);
55    #[wasm_bindgen(method, getter, js_class = "EventSource", js_name = "onmessage")]
56    #[doc = "Getter for the `onmessage` field of this object."]
57    #[doc = ""]
58    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/onmessage)"]
59    #[doc = ""]
60    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
61    pub fn onmessage(this: &EventSource) -> Option<::js_sys::Function>;
62    #[wasm_bindgen(method, setter, js_class = "EventSource", js_name = "onmessage")]
63    #[doc = "Setter for the `onmessage` field of this object."]
64    #[doc = ""]
65    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/onmessage)"]
66    #[doc = ""]
67    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
68    pub fn set_onmessage(this: &EventSource, value: Option<&::js_sys::Function>);
69    #[wasm_bindgen(method, getter, js_class = "EventSource", js_name = "onerror")]
70    #[doc = "Getter for the `onerror` field of this object."]
71    #[doc = ""]
72    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/onerror)"]
73    #[doc = ""]
74    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
75    pub fn onerror(this: &EventSource) -> Option<::js_sys::Function>;
76    #[wasm_bindgen(method, setter, js_class = "EventSource", js_name = "onerror")]
77    #[doc = "Setter for the `onerror` field of this object."]
78    #[doc = ""]
79    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/onerror)"]
80    #[doc = ""]
81    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
82    pub fn set_onerror(this: &EventSource, value: Option<&::js_sys::Function>);
83    #[wasm_bindgen(catch, constructor, js_class = "EventSource")]
84    #[doc = "The `new EventSource(..)` constructor, creating a new instance of `EventSource`."]
85    #[doc = ""]
86    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/EventSource)"]
87    #[doc = ""]
88    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
89    pub fn new(url: &str) -> Result<EventSource, JsValue>;
90    #[cfg(feature = "EventSourceInit")]
91    #[wasm_bindgen(catch, constructor, js_class = "EventSource")]
92    #[doc = "The `new EventSource(..)` constructor, creating a new instance of `EventSource`."]
93    #[doc = ""]
94    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/EventSource)"]
95    #[doc = ""]
96    #[doc = "*This API requires the following crate features to be activated: `EventSource`, `EventSourceInit`*"]
97    pub fn new_with_event_source_init_dict(
98        url: &str,
99        event_source_init_dict: &EventSourceInit,
100    ) -> Result<EventSource, JsValue>;
101    #[wasm_bindgen(method, js_class = "EventSource")]
102    #[doc = "The `close()` method."]
103    #[doc = ""]
104    #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/close)"]
105    #[doc = ""]
106    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
107    pub fn close(this: &EventSource);
108}
109impl EventSource {
110    #[doc = "The `EventSource.CONNECTING` const."]
111    #[doc = ""]
112    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
113    pub const CONNECTING: u16 = 0i64 as u16;
114    #[doc = "The `EventSource.OPEN` const."]
115    #[doc = ""]
116    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
117    pub const OPEN: u16 = 1u64 as u16;
118    #[doc = "The `EventSource.CLOSED` const."]
119    #[doc = ""]
120    #[doc = "*This API requires the following crate features to be activated: `EventSource`*"]
121    pub const CLOSED: u16 = 2u64 as u16;
122}