Skip to content

Commit

Permalink
fix(runtime): trait requirements (#3489)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Feb 17, 2022
1 parent b8e4d65 commit 84895a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-runtime-traits-requirements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-runtime": patch
---

Fix requirements for `RuntimeHandle`, `ClipboardManager`, `GlobalShortcutHandle` and `TrayHandle`.
14 changes: 7 additions & 7 deletions core/tauri-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub enum ActivationPolicy {
}

/// A [`Send`] handle to the runtime.
pub trait RuntimeHandle: Debug + Send + Sized + Clone + 'static {
pub trait RuntimeHandle: Debug + Clone + Send + Sync + Sized + 'static {
type Runtime: Runtime<Handle = Self>;
/// Create a new webview window.
fn create_window(
Expand All @@ -270,7 +270,7 @@ pub trait RuntimeHandle: Debug + Send + Sized + Clone + 'static {
}

/// A global shortcut manager.
pub trait GlobalShortcutManager: Debug {
pub trait GlobalShortcutManager: Debug + Clone + Send + Sync {
/// Whether the application has registered the given `accelerator`.
fn is_registered(&self, accelerator: &str) -> crate::Result<bool>;

Expand All @@ -289,7 +289,7 @@ pub trait GlobalShortcutManager: Debug {
}

/// Clipboard manager.
pub trait ClipboardManager: Debug {
pub trait ClipboardManager: Debug + Clone + Send + Sync {
/// Writes the text into the clipboard as plain text.
fn write_text<T: Into<String>>(&mut self, text: T) -> Result<()>;
/// Read the content in the clipboard as plain text.
Expand All @@ -303,12 +303,12 @@ pub trait Runtime: Sized + 'static {
/// The runtime handle type.
type Handle: RuntimeHandle<Runtime = Self>;
/// The global shortcut manager type.
type GlobalShortcutManager: GlobalShortcutManager + Clone + Send;
type GlobalShortcutManager: GlobalShortcutManager;
/// The clipboard manager type.
type ClipboardManager: ClipboardManager + Clone + Send;
type ClipboardManager: ClipboardManager;
/// The tray handler type.
#[cfg(feature = "system-tray")]
type TrayHandler: menu::TrayHandle + Clone + Send;
type TrayHandler: menu::TrayHandle;

/// Creates a new webview runtime. Must be used on the main thread.
fn new() -> crate::Result<Self>;
Expand Down Expand Up @@ -353,7 +353,7 @@ pub trait Runtime: Sized + 'static {
}

/// Webview dispatcher. A thread-safe handle to the webview API.
pub trait Dispatch: Debug + Clone + Send + Sized + 'static {
pub trait Dispatch: Debug + Clone + Send + Sync + Sized + 'static {
/// The runtime this [`Dispatch`] runs under.
type Runtime: Runtime;

Expand Down
2 changes: 1 addition & 1 deletion core/tauri-runtime/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub enum MenuUpdate {
SetNativeImage(NativeImage),
}

pub trait TrayHandle: fmt::Debug {
pub trait TrayHandle: fmt::Debug + Clone + Send + Sync {
fn set_icon(&self, icon: crate::Icon) -> crate::Result<()>;
fn set_menu(&self, menu: crate::menu::SystemTrayMenu) -> crate::Result<()>;
fn update_item(&self, id: u16, update: MenuUpdate) -> crate::Result<()>;
Expand Down

0 comments on commit 84895a9

Please sign in to comment.