worker_plus_sys/
global.rs

1use wasm_bindgen::prelude::*;
2
3use crate::cache::Caches;
4use crate::{Request, RequestInit};
5
6#[wasm_bindgen]
7extern "C" {
8    #[wasm_bindgen (extends = :: js_sys :: Object , js_name = EventTarget)]
9    #[derive(Debug, Clone, PartialEq, Eq)]
10    #[doc = "The `EventTarget` class."]
11    pub type EventTarget;
12
13    #[wasm_bindgen (extends = EventTarget , extends = :: js_sys :: Object , js_name = WorkerGlobalScope)]
14    #[derive(Debug, Clone, PartialEq, Eq)]
15    #[doc = "The `WorkerGlobalScope` class."]
16    pub type WorkerGlobalScope;
17
18    #[wasm_bindgen (catch , method , structural , js_class = "WorkerGlobalScope" , js_name = atob)]
19    #[doc = "The `atob()` method."]
20    pub fn atob(this: &WorkerGlobalScope, atob: &str) -> Result<String, JsValue>;
21
22    #[wasm_bindgen (catch , method , structural , js_class = "WorkerGlobalScope" , js_name = btoa)]
23    #[doc = "The `btoa()` method."]
24    pub fn btoa(this: &WorkerGlobalScope, btoa: &str) -> Result<String, JsValue>;
25
26    #[wasm_bindgen (method , structural , js_class = "WorkerGlobalScope" , js_name = fetch)]
27    #[doc = "The `fetch()` method."]
28    pub fn fetch_with_request(this: &WorkerGlobalScope, input: &Request) -> ::js_sys::Promise;
29
30    #[wasm_bindgen (method , structural , js_class = "WorkerGlobalScope" , js_name = fetch)]
31    #[doc = "The `fetch()` method."]
32    pub fn fetch_with_str(this: &WorkerGlobalScope, input: &str) -> ::js_sys::Promise;
33
34    #[wasm_bindgen (method , structural , js_class = "WorkerGlobalScope" , js_name = fetch)]
35    #[doc = "The `fetch()` method."]
36    pub fn fetch_with_request_and_init(
37        this: &WorkerGlobalScope,
38        input: &Request,
39        init: &RequestInit,
40    ) -> ::js_sys::Promise;
41
42    #[wasm_bindgen (method , structural , js_class = "WorkerGlobalScope" , js_name = fetch)]
43    #[doc = "The `fetch()` method."]
44    pub fn fetch_with_str_and_init(
45        this: &WorkerGlobalScope,
46        input: &str,
47        init: &RequestInit,
48    ) -> ::js_sys::Promise;
49
50    #[wasm_bindgen(js_name = setTimeout)]
51    pub fn set_timeout(closure: &Closure<dyn FnMut()>, millis: u32) -> u32;
52
53    #[wasm_bindgen(js_name = clearTimeout)]
54    pub fn clear_timeout(id: u32);
55
56    #[wasm_bindgen(js_namespace = console)]
57    pub fn debug(s: &str);
58
59    #[wasm_bindgen(method, structural, getter, js_class = "WorkerGlobalScope")]
60    #[doc = "Provides access to the [caches](https://developers.cloudflare.com/workers/runtime-apis/cache) global"]
61    pub fn caches(this: &WorkerGlobalScope) -> Caches;
62
63    #[wasm_bindgen(js_namespace = console)]
64    pub fn log(s: &str);
65
66    #[wasm_bindgen(js_namespace = console)]
67    pub fn warn(s: &str);
68
69    #[wasm_bindgen(js_namespace = console)]
70    pub fn error(s: &str);
71}