wip: trail & error

This commit is contained in:
Max Coppen 2022-11-03 22:05:12 +01:00
parent 728556dddf
commit c7821f4bd9
4 changed files with 58 additions and 31 deletions

View file

@ -1,3 +1,26 @@
use serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct UpdateManifest {
pub body: String,
pub date: String,
pub version: String
}
#[derive(Deserialize, Debug)]
pub struct UpdateResult {
pub manifest: Option<UpdateManifest>,
pub should_update: bool
}
#[derive(Deserialize)]
pub enum UpdateStatus {
PENDING,
ERROR,
DONE,
UPTODATE
}
/// Install the update if there's one available.
///
/// # Example
@ -17,16 +40,14 @@ pub async fn install_update() {
/// # Example
///
/// ```rust,no_run
/// use tauri_api::clipboard::{write_text, read_text};
/// use tauri_api::updater::{check_update, UpdateResult};
///
/// write_text("Tauri is awesome!").await;
/// assert_eq!(read_text().await, "Tauri is awesome!");
/// let update: UpdateResult = check_update().await;
/// ```
///
/// @returns A promise indicating the success or failure of the operation.
#[inline(always)]
pub async fn check_update() {
inner::checkUpdate().await
pub async fn check_update() -> UpdateResult {
let update = inner::checkUpdate().await;
serde_wasm_bindgen::from_value(update).unwrap()
}
mod inner {
@ -35,6 +56,6 @@ mod inner {
#[wasm_bindgen(module = "/dist/updater.js")]
extern "C" {
pub async fn installUpdate();
pub async fn checkUpdate();
pub async fn checkUpdate() -> JsValue;
}
}