pub struct UpdateBuilder<R: Runtime> { /* private fields */ }
Available on crate feature updater only.
Expand description

An update check builder.

Implementations

Do not use the event system to emit information or listen to install the update.

Sets the current platform’s target name for the updater.

The target is injected in the endpoint URL by replacing {{target}}. Note that this does not affect the {{arch}} variable.

If the updater response JSON includes the platforms field, that object must contain a value for the target key.

By default Tauri uses $OS_NAME as the replacement for {{target}} and $OS_NAME-$ARCH as the key in the platforms object, where $OS_NAME is the current operating system name “linux”, “windows” or “darwin”) and $ARCH is one of the supported architectures (“i686”, “x86_64”, “armv7” or “aarch64”).

See Builder::updater_target for a way to set the target globally.

Examples
Use a macOS Universal binary target name

In this example, we set the updater target only on macOS. On other platforms, we set the default target. Note that {{target}} will be replaced with darwin-universal, but {{arch}} is still the running platform’s architecture.

tauri::Builder::default()
  .setup(|app| {
    let handle = app.handle();
    tauri::async_runtime::spawn(async move {
      let builder = tauri::updater::builder(handle).target(if cfg!(target_os = "macos") {
        "darwin-universal".to_string()
      } else {
        tauri::updater::target().unwrap()
      });
      match builder.check().await {
        Ok(update) => {}
        Err(error) => {}
      }
    });
    Ok(())
  });
Append debug information to the target

This allows you to provide updates for both debug and release applications.

tauri::Builder::default()
  .setup(|app| {
    let handle = app.handle();
    tauri::async_runtime::spawn(async move {
      let kind = if cfg!(debug_assertions) { "debug" } else { "release" };
      let builder = tauri::updater::builder(handle).target(format!("{}-{}", tauri::updater::target().unwrap(), kind));
      match builder.check().await {
        Ok(update) => {}
        Err(error) => {}
      }
    });
    Ok(())
  });
Use the platform’s target triple
tauri::Builder::default()
  .setup(|app| {
    let handle = app.handle();
    tauri::async_runtime::spawn(async move {
      let builder = tauri::updater::builder(handle).target(tauri::utils::platform::target_triple().unwrap());
      match builder.check().await {
        Ok(update) => {}
        Err(error) => {}
      }
    });
    Ok(())
  });

Sets a closure that is invoked to compare the current version and the latest version returned by the updater server. The first argument is the current version, and the second one is the latest version.

The closure must return true if the update should be installed.

Examples
  • Always install the version returned by the server:
tauri::Builder::default()
  .setup(|app| {
    tauri::updater::builder(app.handle()).should_install(|_current, _latest| true);
    Ok(())
  });

Sets the timeout for the requests to the updater endpoints.

Add a Header to the request.

Check if an update is available.

Examples
tauri::Builder::default()
  .setup(|app| {
    let handle = app.handle();
    tauri::async_runtime::spawn(async move {
      match tauri::updater::builder(handle).check().await {
        Ok(update) => {}
        Err(error) => {}
      }
    });
    Ok(())
  });

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.