Struct tauri::Builder [−][src]
pub struct Builder<E, L, MID, TID, A, R> where
E: Tag,
L: Tag,
MID: MenuId,
TID: MenuId,
A: Assets,
R: Runtime, { /* fields omitted */ }
Expand description
Builds a Tauri application.
Implementations
impl<E, L, MID, TID, A, R> Builder<E, L, MID, TID, A, R> where
E: Tag,
L: Tag,
MID: MenuId,
TID: MenuId,
A: Assets,
R: Runtime,
[src]
impl<E, L, MID, TID, A, R> Builder<E, L, MID, TID, A, R> where
E: Tag,
L: Tag,
MID: MenuId,
TID: MenuId,
A: Assets,
R: Runtime,
[src]pub fn invoke_handler<F>(self, invoke_handler: F) -> Self where
F: Fn(Invoke<Args<E, L, MID, TID, A, R>>) + Send + Sync + 'static,
[src]
pub fn invoke_handler<F>(self, invoke_handler: F) -> Self where
F: Fn(Invoke<Args<E, L, MID, TID, A, R>>) + Send + Sync + 'static,
[src]Defines the JS message handler callback.
pub fn setup<F>(self, setup: F) -> Self where
F: Fn(&mut App<Args<E, L, MID, TID, A, R>>) -> Result<(), Box<dyn Error + Send>> + Send + 'static,
[src]
pub fn setup<F>(self, setup: F) -> Self where
F: Fn(&mut App<Args<E, L, MID, TID, A, R>>) -> Result<(), Box<dyn Error + Send>> + Send + 'static,
[src]Defines the setup hook.
pub fn on_page_load<F>(self, on_page_load: F) -> Self where
F: Fn(Window<Args<E, L, MID, TID, A, R>>, PageLoadPayload) + Send + Sync + 'static,
[src]
pub fn on_page_load<F>(self, on_page_load: F) -> Self where
F: Fn(Window<Args<E, L, MID, TID, A, R>>, PageLoadPayload) + Send + Sync + 'static,
[src]Defines the page load hook.
pub fn plugin<P: Plugin<Args<E, L, MID, TID, A, R>> + 'static>(
self,
plugin: P
) -> Self
[src]
pub fn plugin<P: Plugin<Args<E, L, MID, TID, A, R>> + 'static>(
self,
plugin: P
) -> Self
[src]Adds a plugin to the runtime.
pub fn manage<T>(self, state: T) -> Self where
T: Send + Sync + 'static,
[src]
pub fn manage<T>(self, state: T) -> Self where
T: Send + Sync + 'static,
[src]Add state
to the state managed by the application.
This method can be called any number of times as long as each call
refers to a different T
.
Managed state can be retrieved by any request handler via the
State
request guard. In particular, if a value of type T
is managed by Tauri, adding State<T>
to the list of arguments in a
request handler instructs Tauri to retrieve the managed value.
Panics
Panics if state of type T
is already being managed.
Example
use tauri::State; struct MyInt(isize); struct MyString(String); #[tauri::command] fn int_command(state: State<'_, MyInt>) -> String { format!("The stateful int is: {}", state.0) } #[tauri::command] fn string_command<'r>(state: State<'r, MyString>) { println!("state: {}", state.inner().0); } fn main() { tauri::Builder::default() .manage(MyInt(10)) .manage(MyString("Hello, managed state!".to_string())) .run(tauri::generate_context!()) .expect("error while running tauri application"); }
pub fn create_window<F>(self, label: L, url: WindowUrl, setup: F) -> Self where
F: FnOnce(<R::Dispatcher as Dispatch>::WindowBuilder, WebviewAttributes) -> (<R::Dispatcher as Dispatch>::WindowBuilder, WebviewAttributes),
[src]
pub fn create_window<F>(self, label: L, url: WindowUrl, setup: F) -> Self where
F: FnOnce(<R::Dispatcher as Dispatch>::WindowBuilder, WebviewAttributes) -> (<R::Dispatcher as Dispatch>::WindowBuilder, WebviewAttributes),
[src]Creates a new webview window.
pub fn system_tray(self, items: Vec<SystemTrayMenuItem<TID>>) -> Self
[src]
This is supported on crate feature system-tray
only.
pub fn system_tray(self, items: Vec<SystemTrayMenuItem<TID>>) -> Self
[src]system-tray
only.Adds the icon configured on tauri.conf.json
to the system tray with the specified menu items.
pub fn menu(self, menu: Vec<Menu<MID>>) -> Self
[src]
This is supported on crate feature menu
only.
pub fn menu(self, menu: Vec<Menu<MID>>) -> Self
[src]menu
only.Sets the menu to use on all windows.
pub fn on_menu_event<F: Fn(WindowMenuEvent<Args<E, L, MID, TID, A, R>>) + Send + Sync + 'static>(
self,
handler: F
) -> Self
[src]
This is supported on crate feature menu
only.
pub fn on_menu_event<F: Fn(WindowMenuEvent<Args<E, L, MID, TID, A, R>>) + Send + Sync + 'static>(
self,
handler: F
) -> Self
[src]menu
only.Registers a menu event handler for all windows.
pub fn on_window_event<F: Fn(GlobalWindowEvent<Args<E, L, MID, TID, A, R>>) + Send + Sync + 'static>(
self,
handler: F
) -> Self
[src]
pub fn on_window_event<F: Fn(GlobalWindowEvent<Args<E, L, MID, TID, A, R>>) + Send + Sync + 'static>(
self,
handler: F
) -> Self
[src]Registers a window event handler for all windows.
pub fn on_system_tray_event<F: Fn(&AppHandle<Args<E, L, MID, TID, A, R>>, SystemTrayEvent<TID>) + Send + Sync + 'static>(
self,
handler: F
) -> Self
[src]
This is supported on crate feature system-tray
only.
pub fn on_system_tray_event<F: Fn(&AppHandle<Args<E, L, MID, TID, A, R>>, SystemTrayEvent<TID>) + Send + Sync + 'static>(
self,
handler: F
) -> Self
[src]system-tray
only.Registers a system tray event handler.
pub fn register_global_uri_scheme_protocol<N: Into<String>, H: Fn(&str) -> Result<Vec<u8>, Box<dyn Error>> + Send + Sync + 'static>(
self,
uri_scheme: N,
protocol: H
) -> Self
[src]
pub fn register_global_uri_scheme_protocol<N: Into<String>, H: Fn(&str) -> Result<Vec<u8>, Box<dyn Error>> + Send + Sync + 'static>(
self,
uri_scheme: N,
protocol: H
) -> Self
[src]Registers a URI scheme protocol available to all webviews. Leverages setURLSchemeHandler on macOS, AddWebResourceRequestedFilter on Windows and webkit-web-context-register-uri-scheme on Linux.
Arguments
uri_scheme
The URI scheme to register, such asexample
.protocol
the protocol associated with the given URI scheme. It’s a function that takes an URL such asexample://localhost/asset.css
.
Trait Implementations
Auto Trait Implementations
impl<E, L, MID, TID, A, R> !RefUnwindSafe for Builder<E, L, MID, TID, A, R>
impl<E, L, MID, TID, A, R> Send for Builder<E, L, MID, TID, A, R> where
<<R as Runtime>::Dispatcher as Dispatch>::WindowBuilder: Send,
<<R as Runtime>::Dispatcher as Dispatch>::WindowBuilder: Send,
impl<E, L, MID, TID, A, R> !Sync for Builder<E, L, MID, TID, A, R>
impl<E, L, MID, TID, A, R> Unpin for Builder<E, L, MID, TID, A, R> where
L: Unpin,
MID: Unpin,
TID: Unpin,
<<R as Runtime>::Dispatcher as Dispatch>::WindowBuilder: Unpin,
L: Unpin,
MID: Unpin,
TID: Unpin,
<<R as Runtime>::Dispatcher as Dispatch>::WindowBuilder: Unpin,
impl<E, L, MID, TID, A, R> !UnwindSafe for Builder<E, L, MID, TID, A, R>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,