Expand description
The instance of the currently running application.
This type implements Manager
which allows for manipulation of global application items.
Implementations
sourceimpl App<Wry>
impl App<Wry>
APIs specific to the wry runtime.
sourcepub fn wry_plugin<P: PluginBuilder<EventLoopMessage> + 'static>(
&mut self,
plugin: P
)
pub fn wry_plugin<P: PluginBuilder<EventLoopMessage> + 'static>(
&mut self,
plugin: P
)
Adds a tauri_runtime_wry::Plugin
using its tauri_runtime_wry::PluginBuilder
.
Stability
This API is unstable.
sourceimpl<R: Runtime> App<R>
impl<R: Runtime> App<R>
sourcepub fn updater(&self) -> UpdateBuilder<R>
Available on crate feature updater
only.
pub fn updater(&self) -> UpdateBuilder<R>
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(())
});
sourcepub fn tray_handle(&self) -> SystemTrayHandle<R>
Available on crate feature system-tray
only.
pub fn tray_handle(&self) -> SystemTrayHandle<R>
system-tray
only.Gets a handle handle to the system tray.
sourcepub fn path_resolver(&self) -> PathResolver
pub fn path_resolver(&self) -> PathResolver
The path resolver for the application.
sourcepub fn global_shortcut_manager(&self) -> R::GlobalShortcutManager
Available on crate feature global-shortcut
only.
pub fn global_shortcut_manager(&self) -> R::GlobalShortcutManager
global-shortcut
only.Gets a copy of the global shortcut manager instance.
sourcepub fn clipboard_manager(&self) -> R::ClipboardManager
Available on crate feature clipboard
only.
pub fn clipboard_manager(&self) -> R::ClipboardManager
clipboard
only.Gets a copy of the clipboard manager instance.
sourcepub fn config(&self) -> Arc<Config>
pub fn config(&self) -> Arc<Config>
Gets the app’s configuration, defined on the tauri.conf.json
file.
sourcepub fn package_info(&self) -> &PackageInfo
pub fn package_info(&self) -> &PackageInfo
Gets the app’s package information.
sourcepub fn asset_resolver(&self) -> AssetResolver<R>
pub fn asset_resolver(&self) -> AssetResolver<R>
The application’s asset resolver.
sourceimpl<R: Runtime> App<R>
impl<R: Runtime> App<R>
sourcepub fn get_cli_matches(&self) -> Result<Matches>
pub fn get_cli_matches(&self) -> Result<Matches>
Gets the argument matches of the CLI definition configured in tauri.conf.json
.
Examples
tauri::Builder::default()
.setup(|app| {
let matches = app.get_cli_matches()?;
Ok(())
});
sourcepub fn run<F: FnMut(&AppHandle<R>, RunEvent) + 'static>(self, callback: F)
pub fn run<F: FnMut(&AppHandle<R>, RunEvent) + 'static>(self, callback: F)
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();
}
_ => {}
});
sourcepub fn run_iteration(&mut self) -> RunIteration
pub fn run_iteration(&mut self) -> RunIteration
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
sourceimpl<R: Debug + Runtime> Debug for App<R>where
R::GlobalShortcutManager: Debug,
R::ClipboardManager: Debug,
impl<R: Debug + Runtime> Debug for App<R>where
R::GlobalShortcutManager: Debug,
R::ClipboardManager: Debug,
sourceimpl<R: Runtime> Manager<R> for App<R>
impl<R: Runtime> Manager<R> for App<R>
sourcefn app_handle(&self) -> AppHandle<R>
fn app_handle(&self) -> AppHandle<R>
sourcefn emit_all<S: Serialize + Clone>(&self, event: &str, payload: S) -> Result<()>
fn emit_all<S: Serialize + Clone>(&self, event: &str, payload: S) -> Result<()>
sourcefn emit_to<S: Serialize + Clone>(
&self,
label: &str,
event: &str,
payload: S
) -> Result<()>
fn emit_to<S: Serialize + Clone>(
&self,
label: &str,
event: &str,
payload: S
) -> Result<()>
sourcefn listen_global<F>(&self, event: impl Into<String>, handler: F) -> EventHandlerwhere
F: Fn(Event) + Send + 'static,
fn listen_global<F>(&self, event: impl Into<String>, handler: F) -> EventHandlerwhere
F: Fn(Event) + Send + 'static,
sourcefn once_global<F>(&self, event: impl Into<String>, handler: F) -> EventHandlerwhere
F: FnOnce(Event) + Send + 'static,
fn once_global<F>(&self, event: impl Into<String>, handler: F) -> EventHandlerwhere
F: FnOnce(Event) + Send + 'static,
sourcefn trigger_global(&self, event: &str, data: Option<String>)
fn trigger_global(&self, event: &str, data: Option<String>)
sourcefn unlisten(&self, handler_id: EventHandler)
fn unlisten(&self, handler_id: EventHandler)
sourcefn get_window(&self, label: &str) -> Option<Window<R>>
fn get_window(&self, label: &str) -> Option<Window<R>>
sourcefn manage<T>(&self, state: T) -> boolwhere
T: Send + Sync + 'static,
fn manage<T>(&self, state: T) -> boolwhere
T: Send + Sync + 'static,
state
to the state managed by the application. Read moresourcefn state<T>(&self) -> State<'_, T>where
T: Send + Sync + 'static,
fn state<T>(&self) -> State<'_, T>where
T: Send + Sync + 'static,
T
. Read moresourcefn try_state<T>(&self) -> Option<State<'_, T>>where
T: Send + Sync + 'static,
fn try_state<T>(&self) -> Option<State<'_, T>>where
T: Send + Sync + 'static,
T
. Read more