File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " tauri " : patch
3+ ---
4+
5+ Change plugin trait ` initialization ` return type to ` std::result::Result<(), Box<dyn std::error::Error>> ` .
Original file line number Diff line number Diff line change @@ -57,6 +57,9 @@ pub enum Error {
5757 #[ cfg( feature = "updater" ) ]
5858 #[ error( "Updater: {0}" ) ]
5959 TauriUpdater ( #[ from] crate :: updater:: Error ) ,
60+ /// Error initializing plugin.
61+ #[ error( "failed to initialize plugin `{0}`: {1}" ) ]
62+ PluginInitialization ( String , String ) ,
6063}
6164
6265impl From < serde_json:: Error > for Error {
Original file line number Diff line number Diff line change @@ -12,14 +12,17 @@ use crate::{
1212use serde_json:: Value as JsonValue ;
1313use std:: collections:: HashMap ;
1414
15+ /// The plugin result type.
16+ pub type Result < T > = std:: result:: Result < T , Box < dyn std:: error:: Error > > ;
17+
1518/// The plugin interface.
1619pub trait Plugin < M : Params > : Send {
1720 /// The plugin name. Used as key on the plugin config object.
1821 fn name ( & self ) -> & ' static str ;
1922
2023 /// Initialize the plugin.
2124 #[ allow( unused_variables) ]
22- fn initialize ( & mut self , config : JsonValue ) -> crate :: Result < ( ) > {
25+ fn initialize ( & mut self , config : JsonValue ) -> Result < ( ) > {
2326 Ok ( ( ) )
2427 }
2528
@@ -69,7 +72,9 @@ impl<M: Params> PluginStore<M> {
6972 /// Initializes all plugins in the store.
7073 pub ( crate ) fn initialize ( & mut self , config : & PluginConfig ) -> crate :: Result < ( ) > {
7174 self . store . values_mut ( ) . try_for_each ( |plugin| {
72- plugin. initialize ( config. 0 . get ( plugin. name ( ) ) . cloned ( ) . unwrap_or_default ( ) )
75+ plugin
76+ . initialize ( config. 0 . get ( plugin. name ( ) ) . cloned ( ) . unwrap_or_default ( ) )
77+ . map_err ( |e| crate :: Error :: PluginInitialization ( plugin. name ( ) . to_string ( ) , e. to_string ( ) ) )
7378 } )
7479 }
7580
You can’t perform that action at this time.
0 commit comments