mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-01-31 00:45:24 +01:00
39 lines
1.3 KiB
Rust
39 lines
1.3 KiB
Rust
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//! [](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/single-instance)
|
|
//!
|
|
//! Ensure a single instance of your tauri app is running.
|
|
|
|
#![doc(
|
|
html_logo_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png",
|
|
html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png"
|
|
)]
|
|
#![cfg(not(any(target_os = "android", target_os = "ios")))]
|
|
|
|
use tauri::{plugin::TauriPlugin, AppHandle, Manager, Runtime};
|
|
|
|
#[cfg(target_os = "windows")]
|
|
#[path = "platform_impl/windows.rs"]
|
|
mod platform_impl;
|
|
#[cfg(target_os = "linux")]
|
|
#[path = "platform_impl/linux.rs"]
|
|
mod platform_impl;
|
|
#[cfg(target_os = "macos")]
|
|
#[path = "platform_impl/macos.rs"]
|
|
mod platform_impl;
|
|
|
|
pub(crate) type SingleInstanceCallback<R> =
|
|
dyn FnMut(&AppHandle<R>, Vec<String>, String) + Send + Sync + 'static;
|
|
|
|
pub fn init<R: Runtime, F: FnMut(&AppHandle<R>, Vec<String>, String) + Send + Sync + 'static>(
|
|
f: F,
|
|
) -> TauriPlugin<R> {
|
|
platform_impl::init(Box::new(f))
|
|
}
|
|
|
|
pub fn destroy<R: Runtime, M: Manager<R>>(manager: &M) {
|
|
platform_impl::destroy(manager)
|
|
}
|