Skip to main content

Struct tauri::AppHandle

pub struct AppHandle<P: Params = Args<String, String, String, String, EmbeddedAssets, Wry>> { /* fields omitted */ }

A handle to the currently running application.

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

Implementations#

Params#

impl<P: Params> AppHandle<P>

Defined in: app.rs:266

create_window#

pub fn create_window<F>(
    &self, 
    label: P::Label, 
    url: WindowUrl, 
    setup: F
) -> Result<()> where
    F: FnOnce(<<P::Runtime as Runtime>::Dispatcher as Dispatch>::WindowBuilder, WebviewAttributes) -> (<<P::Runtime as Runtime>::Dispatcher as Dispatch>::WindowBuilder, WebviewAttributes), 

Creates a new webview window.

Defined in: app.rs:266

path_resolver#

pub fn path_resolver(&self) -> PathResolver

The path resolver for the application.

Defined in: app.rs:266

global_shortcut_manager#

pub fn global_shortcut_manager(
    &self
) -> <P::Runtime as Runtime>::GlobalShortcutManager

Gets a copy of the global shortcut manager instance.

Defined in: app.rs:266

clipboard_manager#

pub fn clipboard_manager(&self) -> <P::Runtime as Runtime>::ClipboardManager

Gets a copy of the clipboard manager instance.

Defined in: app.rs:266

config#

pub fn config(&self) -> Arc<Config>

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

Defined in: app.rs:266

package_info#

pub fn package_info(&self) -> &PackageInfo

Gets the app’s package information.

Defined in: app.rs:266

Trait Implementations#

Params#

impl<P: Params> Clone for AppHandle<P>

Defined in: app.rs:124-135

clone#

fn clone(&self) -> Self

Returns a copy of the value. Read more

Defined in: app.rs:125-134

clone_from#

pub fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Defined in: clone.rs:130

Params#

impl<'de, P: Params> CommandArg<'de, P> for AppHandle<P>

Defined in: app.rs:137-142

from_command#

fn from_command(command: CommandItem<'de, P>) -> Result<Self, InvokeError>

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

Defined in: app.rs:139-141

Params#

impl<P: Params> Manager<P> for AppHandle<P>

Defined in: app.rs:153

config#

fn config(&self) -> Arc<Config>

The Config the manager was created with.

Defined in: lib.rs:251-253

emit_all#

fn emit_all<E: ?Sized, S>(&self, event: &E, payload: S) -> Result<()> where
    P::Event: Borrow<E>,
    E: TagRef<P::Event>,
    S: Serialize + Clone, 

Emits a event to all windows.

Defined in: lib.rs:256-263

emit_to#

fn emit_to<E: ?Sized, L: ?Sized, S: Serialize + Clone>(
    &self, 
    label: &L, 
    event: &E, 
    payload: S
) -> Result<()> where
    P::Label: Borrow<L>,
    P::Event: Borrow<E>,
    L: TagRef<P::Label>,
    E: TagRef<P::Event>, 

Emits an event to a window with the specified label.

Defined in: lib.rs:266-281

listen_global#

fn listen_global<E: Into<P::Event>, F>(
    &self, 
    event: E, 
    handler: F
) -> EventHandler where
    F: Fn(Event) + Send + 'static, 

Listen to a global event.

Defined in: lib.rs:284-289

once_global#

fn once_global<E: Into<P::Event>, F>(
    &self, 
    event: E, 
    handler: F
) -> EventHandler where
    F: Fn(Event) + Send + 'static, 

Listen to a global event only once.

Defined in: lib.rs:292-297

trigger_global#

fn trigger_global<E: ?Sized>(&self, event: &E, data: Option<String>) where
    P::Event: Borrow<E>,
    E: TagRef<P::Event>, 

Trigger a global event.

Defined in: lib.rs:300-306

unlisten#

fn unlisten(&self, handler_id: EventHandler)

Remove an event listener.

Defined in: lib.rs:309-311

get_window#

fn get_window<L: ?Sized>(&self, label: &L) -> Option<Window<P>> where
    P::Label: Borrow<L>,
    L: TagRef<P::Label>, 

Fetch a single window from the manager.

Defined in: lib.rs:314-320

windows#

fn windows(&self) -> HashMap<P::Label, Window<P>>

Fetch all managed windows.

Defined in: lib.rs:323-325

manage#

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

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

Defined in: lib.rs:329-334

state#

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

Gets the managed state for the type T.

Defined in: lib.rs:337-342

Auto Trait Implementations#

impl<P = Args<String, String, String, String, EmbeddedAssets, Wry>> !RefUnwindSafe for AppHandle<P>#

impl<P> Send for AppHandle<P>#

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

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

impl<P = Args<String, String, String, String, EmbeddedAssets, Wry>> !UnwindSafe for AppHandle<P>#

Blanket Implementations#

Any#

impl<T> Any for T where
    T: 'static + ?Sized, 

Defined in: any.rs:131-135

type_id#

pub fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more

Defined in: any.rs:132

Borrow#

impl<T> Borrow<T> for T where
    T: ?Sized, 

Defined in: borrow.rs:208-213

borrow#

pub fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more

Defined in: borrow.rs:210

BorrowMut#

impl<T> BorrowMut<T> for T where
    T: ?Sized, 

Defined in: borrow.rs:216-220

borrow_mut#

pub fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more

Defined in: borrow.rs:217

From#

impl<T> From<T> for T

Defined in: mod.rs:544-548

from#

pub fn from(t: T) -> T

Performs the conversion.

Defined in: mod.rs:545

Into#

impl<T, U> Into<U> for T where
    U: From<T>, 

Defined in: mod.rs:533-540

into#

pub fn into(self) -> U

Performs the conversion.

Defined in: mod.rs:537

ToOwned#

impl<T> ToOwned for T where
    T: Clone, 

Defined in: borrow.rs:81-93

type Owned = T#

The resulting type after obtaining ownership.

to_owned#

pub fn to_owned(&self) -> T

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

Defined in: borrow.rs:86

clone_into#

pub fn clone_into(&self, target: &mut T)

Defined in: borrow.rs:90

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

recently added

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

TryFrom#

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

Defined in: mod.rs:581-590

type Error = Infallible#

The type returned in the event of a conversion error.

try_from#

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

Performs the conversion.

Defined in: mod.rs:587

TryInto#

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

Defined in: mod.rs:567-576

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

The type returned in the event of a conversion error.

try_into#

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

Performs the conversion.

Defined in: mod.rs:573

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

pub fn vzip(self) -> V#