Browse Source

fix(runtime): trait requirements (#3489)

Lucas Fernandes Nogueira 3 years ago
parent
commit
84895a9cd2

+ 5 - 0
.changes/fix-runtime-traits-requirements.md

@@ -0,0 +1,5 @@
+---
+"tauri-runtime": patch
+---
+
+Fix requirements for `RuntimeHandle`, `ClipboardManager`, `GlobalShortcutHandle` and `TrayHandle`.

+ 7 - 7
core/tauri-runtime/src/lib.rs

@@ -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(
@@ -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>;
 
@@ -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.
@@ -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>;
@@ -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;
 

+ 1 - 1
core/tauri-runtime/src/menu.rs

@@ -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<()>;