Skip to content

Commit b50f182

Browse files
committed
refactor: rename plugin_dyn to plugin_boxed
1 parent 35a340a commit b50f182

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

.changes/plugin-boxed.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
tauri: "minor:enhance"
3+
---
4+
5+
Add `AppHandle::plugin_boxed` and `Builder::plugin_boxed` methods to allow adding plugins in the form of boxed trait objects.

.changes/plugin-dyn.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

crates/tauri/src/app.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,16 +484,17 @@ impl<R: Runtime> AppHandle<R> {
484484
/// Ok(())
485485
/// });
486486
/// ```
487+
#[inline]
487488
pub fn plugin<P: Plugin<R> + 'static>(&self, plugin: P) -> crate::Result<()> {
488-
self.plugin_dyn(Box::new(plugin))
489+
self.plugin_boxed(Box::new(plugin))
489490
}
490491

491492
/// Adds a Tauri application plugin.
492493
///
493494
/// This method is similar to [`Self::plugin`],
494495
/// but accepts a boxed trait object instead of a generic type.
495496
#[cfg_attr(feature = "tracing", tracing::instrument(name = "app::plugin::register", skip(plugin), fields(name = plugin.name())))]
496-
pub fn plugin_dyn(&self, mut plugin: Box<dyn Plugin<R>>) -> crate::Result<()> {
497+
pub fn plugin_boxed(&self, mut plugin: Box<dyn Plugin<R>>) -> crate::Result<()> {
497498
let mut store = self.manager().plugins.lock().unwrap();
498499
store.initialize(&mut plugin, self, &self.config().plugins)?;
499500
store.register(plugin);
@@ -1688,17 +1689,18 @@ tauri::Builder::default()
16881689
/// tauri::Builder::default()
16891690
/// .plugin(plugin::init());
16901691
/// ```
1692+
#[inline]
16911693
#[must_use]
16921694
pub fn plugin<P: Plugin<R> + 'static>(self, plugin: P) -> Self {
1693-
self.plugin_dyn(Box::new(plugin))
1695+
self.plugin_boxed(Box::new(plugin))
16941696
}
16951697

16961698
/// Adds a Tauri application plugin.
16971699
///
16981700
/// This method is similar to [`Self::plugin`],
16991701
/// but accepts a boxed trait object instead of a generic type.
17001702
#[must_use]
1701-
pub fn plugin_dyn(mut self, plugin: Box<dyn Plugin<R>>) -> Self {
1703+
pub fn plugin_boxed(mut self, plugin: Box<dyn Plugin<R>>) -> Self {
17021704
self.plugins.register(plugin);
17031705
self
17041706
}

0 commit comments

Comments
 (0)