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
//! Disable and enable autostart
//!
//!

/// Returns a bool checking if autostart is enabled.
#[inline(always)]
pub async fn disable() -> crate::Result<()> {
    let raw = base::disable().await?;

    Ok(raw)
}

/// Returns a bool checking if autostart is enabled.
#[inline(always)]
pub async fn enable() -> crate::Result<()> {
    let raw = base::enable().await?;

    Ok(raw)
}

/// Returns a bool checking if autostart is enabled.
#[inline(always)]
pub async fn is_enabled() -> crate::Result<bool> {
    let raw = base::is_enabled().await?;

    Ok(serde_wasm_bindgen::from_value(raw)?)
}

mod base {
    use wasm_bindgen::prelude::*;

    #[wasm_bindgen(module = "/src/scripts/plugins/autostart.js")]
    extern "C" {
        #[wasm_bindgen(catch)]
        pub async fn disable() -> Result<(), JsValue>;
        #[wasm_bindgen(catch)]
        pub async fn enable() -> Result<(), JsValue>;
        #[wasm_bindgen(catch, js_name = "isEnabled")]
        pub async fn is_enabled() -> Result<JsValue, JsValue>;
    }
}