pub trait Plugin<T: Theme, V: VectorGraphicsInterface>: 'static {
// Required method
fn name(&self) -> &'static str;
// Provided methods
fn on_register(&mut self, _manager: &mut PluginManager<T, V>) { ... }
fn on_unregister(&mut self, _manager: &mut PluginManager<T, V>) { ... }
fn init(
&mut self,
_event_loop: &mut EventLoop<()>,
_update: &UpdateManager,
_window: &mut WindowAttributes,
_config: &mut MayConfig<T, V>,
) { ... }
fn on_resume(
&mut self,
_config: &mut MayConfig<T, V>,
_scene: &mut V::Scene,
_taffy: &mut TaffyTree,
_window_node: NodeId,
_info: &mut AppInfo,
_update: &UpdateManager,
_last_update: &mut Instant,
_event_loop: &ActiveEventLoop,
) { ... }
fn on_update(
&mut self,
_config: &mut MayConfig<T, V>,
_window: &Arc<Window>,
_scene: &mut V::Scene,
_taffy: &mut TaffyTree,
_window_node: NodeId,
_info: &mut AppInfo,
_update: &UpdateManager,
_last_update: &mut Instant,
_event_loop: &ActiveEventLoop,
) { ... }
fn on_window_event(
&mut self,
_event: &mut WindowEvent,
_config: &mut MayConfig<T, V>,
_window: &Arc<Window>,
_scene: &mut V::Scene,
_taffy: &mut TaffyTree,
_window_node: NodeId,
_info: &mut AppInfo,
_update: &UpdateManager,
_last_update: &mut Instant,
_event_loop: &ActiveEventLoop,
) { ... }
fn on_suspended(
&mut self,
_config: &mut MayConfig<T, V>,
_scene: &mut V::Scene,
_taffy: &mut TaffyTree,
_window_node: NodeId,
_info: &mut AppInfo,
_update: &UpdateManager,
_last_update: &mut Instant,
_event_loop: &ActiveEventLoop,
) { ... }
}Expand description
A plugin interface for maycoon applications.
Plugins are used to extend functionality and manipulate the inner state of applications. Beware that tampering with the application state may cause crashes or other issues if not done correctly.
All functions defined in this trait get called before the app handler logic and therefore can control the application flow.
Required Methods§
Provided Methods§
Sourcefn on_register(&mut self, _manager: &mut PluginManager<T, V>)
fn on_register(&mut self, _manager: &mut PluginManager<T, V>)
Called when the plugin is registered using PluginManager::register.
Sourcefn on_unregister(&mut self, _manager: &mut PluginManager<T, V>)
fn on_unregister(&mut self, _manager: &mut PluginManager<T, V>)
Called when the plugin is unregistered using PluginManager::unregister.
Sourcefn init(
&mut self,
_event_loop: &mut EventLoop<()>,
_update: &UpdateManager,
_window: &mut WindowAttributes,
_config: &mut MayConfig<T, V>,
)
fn init( &mut self, _event_loop: &mut EventLoop<()>, _update: &UpdateManager, _window: &mut WindowAttributes, _config: &mut MayConfig<T, V>, )
Called right before initializing the AppHandler and running the event loop.
Sourcefn on_resume(
&mut self,
_config: &mut MayConfig<T, V>,
_scene: &mut V::Scene,
_taffy: &mut TaffyTree,
_window_node: NodeId,
_info: &mut AppInfo,
_update: &UpdateManager,
_last_update: &mut Instant,
_event_loop: &ActiveEventLoop,
)
fn on_resume( &mut self, _config: &mut MayConfig<T, V>, _scene: &mut V::Scene, _taffy: &mut TaffyTree, _window_node: NodeId, _info: &mut AppInfo, _update: &UpdateManager, _last_update: &mut Instant, _event_loop: &ActiveEventLoop, )
Called when the application is resumed after being suspended or when it’s first started.
Desktop applications typically don’t get suspended and this function is only called once, while mobile apps can be suspended and resumed.
Sourcefn on_update(
&mut self,
_config: &mut MayConfig<T, V>,
_window: &Arc<Window>,
_scene: &mut V::Scene,
_taffy: &mut TaffyTree,
_window_node: NodeId,
_info: &mut AppInfo,
_update: &UpdateManager,
_last_update: &mut Instant,
_event_loop: &ActiveEventLoop,
)
fn on_update( &mut self, _config: &mut MayConfig<T, V>, _window: &Arc<Window>, _scene: &mut V::Scene, _taffy: &mut TaffyTree, _window_node: NodeId, _info: &mut AppInfo, _update: &UpdateManager, _last_update: &mut Instant, _event_loop: &ActiveEventLoop, )
Called right before the application handler tries to update the application and figure out what updates to apply.
Sourcefn on_window_event(
&mut self,
_event: &mut WindowEvent,
_config: &mut MayConfig<T, V>,
_window: &Arc<Window>,
_scene: &mut V::Scene,
_taffy: &mut TaffyTree,
_window_node: NodeId,
_info: &mut AppInfo,
_update: &UpdateManager,
_last_update: &mut Instant,
_event_loop: &ActiveEventLoop,
)
fn on_window_event( &mut self, _event: &mut WindowEvent, _config: &mut MayConfig<T, V>, _window: &Arc<Window>, _scene: &mut V::Scene, _taffy: &mut TaffyTree, _window_node: NodeId, _info: &mut AppInfo, _update: &UpdateManager, _last_update: &mut Instant, _event_loop: &ActiveEventLoop, )
Called when a window event is received.
Sourcefn on_suspended(
&mut self,
_config: &mut MayConfig<T, V>,
_scene: &mut V::Scene,
_taffy: &mut TaffyTree,
_window_node: NodeId,
_info: &mut AppInfo,
_update: &UpdateManager,
_last_update: &mut Instant,
_event_loop: &ActiveEventLoop,
)
fn on_suspended( &mut self, _config: &mut MayConfig<T, V>, _scene: &mut V::Scene, _taffy: &mut TaffyTree, _window_node: NodeId, _info: &mut AppInfo, _update: &UpdateManager, _last_update: &mut Instant, _event_loop: &ActiveEventLoop, )
Called when the application is suspended.