pub trait Plugin: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn version(&self) -> &'static str;
fn pre_initialize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 dyn ServerContext,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn handle_event<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
event_id: &'life1 EventId,
event: &'life2 dyn GameEvent,
context: &'life3 dyn ServerContext,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn subscribed_events(&self) -> Vec<EventId>;
fn shutdown<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 dyn ServerContext,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn initialize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 (dyn ServerContext + 'static),
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
Expand description
Plugin trait that all plugins must implement
Required Methods§
Sourcefn pre_initialize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 dyn ServerContext,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn pre_initialize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 dyn ServerContext,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Pre-initialize the plugin (This is where you register ALL event handlers)
Sourcefn handle_event<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
event_id: &'life1 EventId,
event: &'life2 dyn GameEvent,
context: &'life3 dyn ServerContext,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn handle_event<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
event_id: &'life1 EventId,
event: &'life2 dyn GameEvent,
context: &'life3 dyn ServerContext,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Handle an event
Sourcefn subscribed_events(&self) -> Vec<EventId>
fn subscribed_events(&self) -> Vec<EventId>
Get event IDs this plugin wants to listen to
Sourcefn shutdown<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 dyn ServerContext,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn shutdown<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 dyn ServerContext,
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Shutdown the plugin
Provided Methods§
Sourcefn initialize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 (dyn ServerContext + 'static),
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn initialize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 (dyn ServerContext + 'static),
) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Initialize the plugin (This is where you load resources, send events to other plugins, etc.)