Skip to main content

Module

Trait Module 

Source
pub trait Module: Send + Sync {
    // Required methods
    fn init<'life0, 'async_trait>(
        &'life0 mut self,
        context: ModuleContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), ModuleError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn start<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), ModuleError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn stop<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), ModuleError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn shutdown<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), ModuleError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn metadata(&self) -> &ModuleMetadata;
    fn state(&self) -> ModuleState;
}
Expand description

Module trait that all modules must implement

This trait is implemented by module binaries (separate processes), not directly by Rust code in the node. The IPC layer translates between this trait interface and the actual module process.

Required Methods§

Source

fn init<'life0, 'async_trait>( &'life0 mut self, context: ModuleContext, ) -> Pin<Box<dyn Future<Output = Result<(), ModuleError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Initialize the module with given context

Called when module is first loaded. Module should validate configuration and prepare for operation.

Source

fn start<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), ModuleError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Start the module

Module should begin its main processing loop here.

Source

fn stop<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), ModuleError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Stop the module (graceful shutdown)

Module should clean up resources and stop processing.

Source

fn shutdown<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), ModuleError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Shutdown the module (forced shutdown)

Called when node is shutting down or module is being removed. Module must terminate immediately.

Source

fn metadata(&self) -> &ModuleMetadata

Get module metadata

Source

fn state(&self) -> ModuleState

Get current module state

Implementors§