@@ -29,13 +29,13 @@ impl From<serde_json::Error> for Error {
29
29
30
30
/// The plugin interface.
31
31
#[ async_trait:: async_trait]
32
- pub trait Plugin < D : ApplicationDispatcherExt + ' static > : Sync {
32
+ pub trait Plugin < D : ApplicationDispatcherExt + ' static > : Send + Sync {
33
33
/// The plugin name. Used as key on the plugin config object.
34
34
fn name ( & self ) -> & ' static str ;
35
35
36
36
/// Initialize the plugin.
37
37
#[ allow( unused_variables) ]
38
- async fn initialize ( & self , config : String ) -> Result < ( ) , Error > {
38
+ async fn initialize ( & mut self , config : String ) -> Result < ( ) , Error > {
39
39
Ok ( ( ) )
40
40
}
41
41
@@ -46,15 +46,15 @@ pub trait Plugin<D: ApplicationDispatcherExt + 'static>: Sync {
46
46
47
47
/// Callback invoked when the webview is created.
48
48
#[ allow( unused_variables) ]
49
- async fn created ( & self , dispatcher : D ) { }
49
+ async fn created ( & mut self , dispatcher : D ) { }
50
50
51
51
/// Callback invoked when the webview is ready.
52
52
#[ allow( unused_variables) ]
53
- async fn ready ( & self , dispatcher : D ) { }
53
+ async fn ready ( & mut self , dispatcher : D ) { }
54
54
55
55
/// Add invoke_handler API extension commands.
56
56
#[ allow( unused_variables) ]
57
- async fn extend_api ( & self , dispatcher : D , payload : & str ) -> Result < ( ) , Error > {
57
+ async fn extend_api ( & mut self , dispatcher : D , payload : & str ) -> Result < ( ) , Error > {
58
58
Err ( Error :: UnknownApi )
59
59
}
60
60
}
@@ -75,9 +75,9 @@ pub(crate) async fn initialize<D: ApplicationDispatcherExt + 'static>(
75
75
store : & PluginStore < D > ,
76
76
plugins_config : PluginConfig ,
77
77
) -> crate :: Result < ( ) > {
78
- let plugins = store. lock ( ) . await ;
78
+ let mut plugins = store. lock ( ) . await ;
79
79
let mut futures = Vec :: new ( ) ;
80
- for plugin in plugins. iter ( ) {
80
+ for plugin in plugins. iter_mut ( ) {
81
81
let plugin_config = plugins_config. get ( plugin. name ( ) ) ;
82
82
futures. push ( plugin. initialize ( plugin_config) ) ;
83
83
}
@@ -92,9 +92,9 @@ pub(crate) async fn initialize<D: ApplicationDispatcherExt + 'static>(
92
92
pub ( crate ) async fn init_script < D : ApplicationDispatcherExt + ' static > (
93
93
store : & PluginStore < D > ,
94
94
) -> String {
95
- let plugins = store. lock ( ) . await ;
95
+ let mut plugins = store. lock ( ) . await ;
96
96
let mut futures = Vec :: new ( ) ;
97
- for plugin in plugins. iter ( ) {
97
+ for plugin in plugins. iter_mut ( ) {
98
98
futures. push ( plugin. init_script ( ) ) ;
99
99
}
100
100
@@ -111,9 +111,9 @@ pub(crate) async fn created<D: ApplicationDispatcherExt + 'static>(
111
111
store : & PluginStore < D > ,
112
112
dispatcher : & mut D ,
113
113
) {
114
- let plugins = store. lock ( ) . await ;
114
+ let mut plugins = store. lock ( ) . await ;
115
115
let mut futures = Vec :: new ( ) ;
116
- for plugin in plugins. iter ( ) {
116
+ for plugin in plugins. iter_mut ( ) {
117
117
futures. push ( plugin. created ( dispatcher. clone ( ) ) ) ;
118
118
}
119
119
join_all ( futures) . await ;
@@ -123,9 +123,9 @@ pub(crate) async fn ready<D: ApplicationDispatcherExt + 'static>(
123
123
store : & PluginStore < D > ,
124
124
dispatcher : & mut D ,
125
125
) {
126
- let plugins = store. lock ( ) . await ;
126
+ let mut plugins = store. lock ( ) . await ;
127
127
let mut futures = Vec :: new ( ) ;
128
- for plugin in plugins. iter ( ) {
128
+ for plugin in plugins. iter_mut ( ) {
129
129
futures. push ( plugin. ready ( dispatcher. clone ( ) ) ) ;
130
130
}
131
131
join_all ( futures) . await ;
@@ -136,8 +136,8 @@ pub(crate) async fn extend_api<D: ApplicationDispatcherExt + 'static>(
136
136
dispatcher : & mut D ,
137
137
arg : & str ,
138
138
) -> Result < bool , Error > {
139
- let plugins = store. lock ( ) . await ;
140
- for ext in plugins. iter ( ) {
139
+ let mut plugins = store. lock ( ) . await ;
140
+ for ext in plugins. iter_mut ( ) {
141
141
match ext. extend_api ( dispatcher. clone ( ) , arg) . await {
142
142
Ok ( _) => {
143
143
return Ok ( true ) ;
0 commit comments