Skip to main content

Struct tauri::AppHandle

pub struct AppHandle<R: Runtime = Wry> { /* fields omitted */ }

Expand description

A handle to the currently running application.

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

Implementations#

impl AppHandle<Wry>[src]#

pub fn create_tao_window<F: FnOnce() -> (String, WryWindowBuilder) + Send + 'static>( &self, f: F ) -> Result<Arc<Window>>[src]#

Create a new tao window using a callback. The event loop must be running at this point.

pub fn send_tao_window_event( &self, window_id: WindowId, message: WindowMessage ) -> Result<()>[src]#

Sends a window message to the event loop.

impl<R: Runtime> AppHandle<R>[src]#

pub fn plugin<P: Plugin<R> + 'static>(&self, plugin: P) -> Result<()>[src]#

Adds a plugin to the runtime.

pub fn exit(&self, exit_code: i32)[src]#

Exits the app

impl<R: Runtime> AppHandle<R>[src]#

pub fn create_window<F>( &self, label: impl Into<String>, url: WindowUrl, setup: F ) -> Result<()> where F: FnOnce(<R::Dispatcher as Dispatch>::WindowBuilder, WebviewAttributes) -> (<R::Dispatcher as Dispatch>::WindowBuilder, WebviewAttributes),[src]#

Creates a new webview window.

pub fn path_resolver(&self) -> PathResolver[src]#

The path resolver for the application.

pub fn global_shortcut_manager(&self) -> R::GlobalShortcutManager[src]#

Gets a copy of the global shortcut manager instance.

pub fn clipboard_manager(&self) -> R::ClipboardManager[src]#

Gets a copy of the clipboard manager instance.

pub fn config(&self) -> Arc<Config>[src]#

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

pub fn package_info(&self) -> &PackageInfo[src]#

Gets the app’s package information.

Trait Implementations#

impl<R: Runtime> Clone for AppHandle<R>[src]#

fn clone(&self) -> Self[src]#

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]#

Performs copy-assignment from source. Read more

impl<'de, R: Runtime> CommandArg<'de, R> for AppHandle<R>[src]#

fn from_command(command: CommandItem<'de, R>) -> Result<Self, InvokeError>[src]#

Grabs the Window from the CommandItem and returns the associated AppHandle. This will never fail.

impl<R: Debug + Runtime> Debug for AppHandle<R> where R::Handle: Debug, R::GlobalShortcutManager: Debug, R::ClipboardManager: Debug,[src]#

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]#

Formats the value using the given formatter. Read more

impl<R: Runtime> Manager<R> for AppHandle<R>[src]#

fn config(&self) -> Arc<Config>[src]#

The Config the manager was created with.

fn emit_all<S: Serialize + Clone>(&self, event: &str, payload: S) -> Result<()>[src]#

Emits a event to all windows.

fn emit_to<S: Serialize + Clone>( &self, label: &str, event: &str, payload: S ) -> Result<()>[src]#

Emits an event to a window with the specified label.

fn listen_global<F>(&self, event: impl Into<String>, handler: F) -> EventHandler where F: Fn(EmittedEvent) + Send + 'static,[src]#

Listen to a global event.

fn once_global<F>(&self, event: impl Into<String>, handler: F) -> EventHandler where F: Fn(EmittedEvent) + Send + 'static,[src]#

Listen to a global event only once.

fn trigger_global(&self, event: &str, data: Option<String>)[src]#

Trigger a global event.

fn unlisten(&self, handler_id: EventHandler)[src]#

Remove an event listener.

fn get_window(&self, label: &str) -> Option<Window<R>>[src]#

Fetch a single window from the manager.

fn windows(&self) -> HashMap<String, Window<R>>[src]#

Fetch all managed windows.

fn manage<T>(&self, state: T) where T: Send + Sync + 'static,[src]#

Add state to the state managed by the application. See crate::Builder for instructions. Read more

fn state<T>(&self) -> State<'_, T> where T: Send + Sync + 'static,[src]#

Gets the managed state for the type T. Panics if the type is not managed.

fn try_state<T>(&self) -> Option<State<'_, T>> where T: Send + Sync + 'static,[src]#

Tries to get the managed state for the type T. Returns None if the type is not managed.

Auto Trait Implementations#

impl<R = Wry> \!RefUnwindSafe for AppHandle<R>#

impl<R> Send for AppHandle<R>#

impl<R> Sync for AppHandle<R> where <R as Runtime>::ClipboardManager: Sync, <R as Runtime>::GlobalShortcutManager: Sync, <R as Runtime>::Handle: Sync,#

impl<R> Unpin for AppHandle<R> where <R as Runtime>::ClipboardManager: Unpin, <R as Runtime>::GlobalShortcutManager: Unpin, <R as Runtime>::Handle: Unpin,#

impl<R = Wry> \!UnwindSafe for AppHandle<R>#

Blanket Implementations#

impl<T> Any for T where T: 'static + ?Sized,[src]#

pub fn type_id(&self) -> TypeId[src]#

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where T: ?Sized,[src]#

pub fn borrow(&self) -> &T[src]#

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where T: ?Sized,[src]#

pub fn borrow_mut(&mut self) -> &mutT[src]#

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]#

pub fn from(t: T) -> T[src]#

Performs the conversion.

impl<T, U> Into<U> for T where U: From<T>,[src]#

pub fn into(self) -> U[src]#

Performs the conversion.

impl<T> ToOwned for T where T: Clone,[src]#

type Owned = T#

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]#

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mutT)[src]#

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where U: Into<T>,[src]#

type Error = Infallible#

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]#

Performs the conversion.

impl<T, U> TryInto<U> for T where U: TryFrom<T>,[src]#

type Error = <U as TryFrom<T>>::Error#

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]#

Performs the conversion.

impl<V, T> VZip<V> for T where V: MultiLane<T>,#

pub fn vzip(self) -> V#