Struct tauri::App

source · []
pub struct App<R: Runtime = Wry> { /* private fields */ }
Expand description

The instance of the currently running application.

This type implements Manager which allows for manipulation of global application items.

Implementations

This is supported on crate feature updater only.

Gets the updater builder to manually check if an update is available.

Examples
tauri::Builder::default()
  .setup(|app| {
    let handle = app.handle();
    tauri::async_runtime::spawn(async move {
     let response = handle.updater().check().await;
    });
    Ok(())
  });
👎 Deprecated since 1.0.0-rc.4:

The window_builder function offers an easier API with extended functionality

Creates a new webview window.

Data URLs are only supported with the window-data-url feature flag.

See crate::window::WindowBuilder::new for an API with extended functionality.

This is supported on crate feature system-tray only.

Gets a handle handle to the system tray.

The path resolver for the application.

Gets a copy of the global shortcut manager instance.

Gets a copy of the clipboard manager instance.

Gets the app’s configuration, defined on the tauri.conf.json file.

Gets the app’s package information.

The application’s asset resolver.

Gets a handle to the application instance.

Runs the application.

Examples
let app = tauri::Builder::default()
  // on an actual app, remove the string argument
  .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
  .expect("error while building tauri application");
app.run(|_app_handle, event| match event {
  tauri::RunEvent::ExitRequested { api, .. } => {
    api.prevent_exit();
  }
  _ => {}
});

Runs a iteration of the runtime event loop and immediately return.

Note that when using this API, app cleanup is not automatically done. The cleanup calls crate::api::process::kill_children so you may want to call that function before exiting the application. Additionally, the cleanup calls AppHandle#remove_system_tray (Windows only).

Examples
let mut app = tauri::Builder::default()
  // on an actual app, remove the string argument
  .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
  .expect("error while building tauri application");
loop {
  let iteration = app.run_iteration();
  if iteration.window_count == 0 {
    break;
  }
}

Trait Implementations

Formats the value using the given formatter. Read more

The application handle associated with this manager.

The Config the manager was created with.

Emits a event to all windows.

Emits an event to a window with the specified label.

Listen to a global event.

Listen to a global event only once.

Trigger a global event.

Remove an event listener.

Fetch a single window from the manager.

Fetch all managed windows.

Add state to the state managed by the application. Read more

Retrieves the managed state for the type T. Read more

Attempts to retrieve the managed state for the type T. Read more

Gets the managed Env.

Gets the scope for the filesystem APIs.

Gets the scope for the asset protocol.

Gets the scope for the shell execute APIs.

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.