#Check for updates example doesn't work out of the box

2 messages · Page 1 of 1 (latest)

tall blaze
#

I'm new to Rust so apologies if I'm doing something dumb.

I'm using this example code:

use tauri_plugin_updater::UpdaterExt;

pub fn run() {
  tauri::Builder::default()
    .setup(|app| {
      let handle = app.handle().clone();
      tauri::async_runtime::spawn(async move {
        update(handle).await;
      });
      Ok(())
    })
}
async fn update(app: tauri::AppHandle) -> tauri::Result<()> {
  if let Some(update) = app.updater()?.check().await? {
    let mut downloaded = 0;

    // alternatively we could also call update.download() and update.install() separately
    update.download_and_install(|chunk_length, content_length| {
      downloaded += chunk_length;
      println!("downloaded {downloaded} from {content_length:?}");
    }, || {
      println!("download finished");
    }).await?;

    println!("update installed");
    app.restart();
  }

  Ok(())
}

But I get this error where the ? operators are

? couldn't convert the error to tauri::Error
the question mark operation (?) implicitly performs a conversion on the error value using the From trait
the following other types implement trait From<T>:
  tauri::Error implements From<anyhow::Error>
  tauri::Error implements From<getrandom::error::Error>
  tauri::Error implements From<glob::PatternError>
  tauri::Error implements From<muda::error::Error>
  tauri::Error implements From<muda::icon::BadIcon>
  tauri::Error implements From<raw_window_handle::HandleError>
  tauri::Error implements From<serde_json::Error>
  tauri::Error implements From<std::io::Error>
and 2 others

Any idea why this isn't working as written in the example?

unique echo