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§
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn metadata(&self) -> &ModuleMetadata
fn metadata(&self) -> &ModuleMetadata
Get module metadata
Sourcefn state(&self) -> ModuleState
fn state(&self) -> ModuleState
Get current module state