Trait Plugin

Source
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§

Source

fn name(&self) -> &'static str

Plugin name (used for default namespace)

Source

fn version(&self) -> &'static str

Plugin version

Source

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)

Source

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

Source

fn subscribed_events(&self) -> Vec<EventId>

Get event IDs this plugin wants to listen to

Source

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§

Source

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.)

Implementors§