@@ -29,13 +29,13 @@ impl From<serde_json::Error> for Error {
2929
3030/// The plugin interface.
3131#[ async_trait:: async_trait]
32- pub trait Plugin < D : ApplicationDispatcherExt + ' static > : Sync {
32+ pub trait Plugin < D : ApplicationDispatcherExt + ' static > : Send + Sync {
3333 /// The plugin name. Used as key on the plugin config object.
3434 fn name ( & self ) -> & ' static str ;
3535
3636 /// Initialize the plugin.
3737 #[ allow( unused_variables) ]
38- async fn initialize ( & self , config : String ) -> Result < ( ) , Error > {
38+ async fn initialize ( & mut self , config : String ) -> Result < ( ) , Error > {
3939 Ok ( ( ) )
4040 }
4141
@@ -46,15 +46,15 @@ pub trait Plugin<D: ApplicationDispatcherExt + 'static>: Sync {
4646
4747 /// Callback invoked when the webview is created.
4848 #[ allow( unused_variables) ]
49- async fn created ( & self , dispatcher : D ) { }
49+ async fn created ( & mut self , dispatcher : D ) { }
5050
5151 /// Callback invoked when the webview is ready.
5252 #[ allow( unused_variables) ]
53- async fn ready ( & self , dispatcher : D ) { }
53+ async fn ready ( & mut self , dispatcher : D ) { }
5454
5555 /// Add invoke_handler API extension commands.
5656 #[ 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 > {
5858 Err ( Error :: UnknownApi )
5959 }
6060}
@@ -75,9 +75,9 @@ pub(crate) async fn initialize<D: ApplicationDispatcherExt + 'static>(
7575 store : & PluginStore < D > ,
7676 plugins_config : PluginConfig ,
7777) -> crate :: Result < ( ) > {
78- let plugins = store. lock ( ) . await ;
78+ let mut plugins = store. lock ( ) . await ;
7979 let mut futures = Vec :: new ( ) ;
80- for plugin in plugins. iter ( ) {
80+ for plugin in plugins. iter_mut ( ) {
8181 let plugin_config = plugins_config. get ( plugin. name ( ) ) ;
8282 futures. push ( plugin. initialize ( plugin_config) ) ;
8383 }
@@ -92,9 +92,9 @@ pub(crate) async fn initialize<D: ApplicationDispatcherExt + 'static>(
9292pub ( crate ) async fn init_script < D : ApplicationDispatcherExt + ' static > (
9393 store : & PluginStore < D > ,
9494) -> String {
95- let plugins = store. lock ( ) . await ;
95+ let mut plugins = store. lock ( ) . await ;
9696 let mut futures = Vec :: new ( ) ;
97- for plugin in plugins. iter ( ) {
97+ for plugin in plugins. iter_mut ( ) {
9898 futures. push ( plugin. init_script ( ) ) ;
9999 }
100100
@@ -111,9 +111,9 @@ pub(crate) async fn created<D: ApplicationDispatcherExt + 'static>(
111111 store : & PluginStore < D > ,
112112 dispatcher : & mut D ,
113113) {
114- let plugins = store. lock ( ) . await ;
114+ let mut plugins = store. lock ( ) . await ;
115115 let mut futures = Vec :: new ( ) ;
116- for plugin in plugins. iter ( ) {
116+ for plugin in plugins. iter_mut ( ) {
117117 futures. push ( plugin. created ( dispatcher. clone ( ) ) ) ;
118118 }
119119 join_all ( futures) . await ;
@@ -123,9 +123,9 @@ pub(crate) async fn ready<D: ApplicationDispatcherExt + 'static>(
123123 store : & PluginStore < D > ,
124124 dispatcher : & mut D ,
125125) {
126- let plugins = store. lock ( ) . await ;
126+ let mut plugins = store. lock ( ) . await ;
127127 let mut futures = Vec :: new ( ) ;
128- for plugin in plugins. iter ( ) {
128+ for plugin in plugins. iter_mut ( ) {
129129 futures. push ( plugin. ready ( dispatcher. clone ( ) ) ) ;
130130 }
131131 join_all ( futures) . await ;
@@ -136,8 +136,8 @@ pub(crate) async fn extend_api<D: ApplicationDispatcherExt + 'static>(
136136 dispatcher : & mut D ,
137137 arg : & str ,
138138) -> 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 ( ) {
141141 match ext. extend_api ( dispatcher. clone ( ) , arg) . await {
142142 Ok ( _) => {
143143 return Ok ( true ) ;
0 commit comments