DMSCModule

Trait DMSCModule 

Source
pub trait DMSCModule: Send + Sync {
    // Required method
    fn name(&self) -> &str;

    // Provided methods
    fn is_critical(&self) -> bool { ... }
    fn priority(&self) -> i32 { ... }
    fn dependencies(&self) -> Vec<&str> { ... }
    fn init<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut DMSCServiceContext,
    ) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn before_start<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut DMSCServiceContext,
    ) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn start<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut DMSCServiceContext,
    ) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn after_start<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut DMSCServiceContext,
    ) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn before_shutdown<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut DMSCServiceContext,
    ) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn shutdown<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut DMSCServiceContext,
    ) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn after_shutdown<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut DMSCServiceContext,
    ) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Public asynchronous service module trait.

This trait defines the public interface for asynchronous service modules in DMSC. It provides a comprehensive lifecycle management system with multiple phases.

§Usage

use dmsc::core::{DMSCModule, DMSCResult, DMSCServiceContext};
use async_trait::async_trait;
 
struct MyAsyncModule;
 
#[async_trait]
impl DMSCModule for MyAsyncModule {
    fn name(&self) -> &str {
        "my_async_module"
    }
     
    async fn start(&mut self, ctx: &mut DMSCServiceContext) -> DMSCResult<()> {
        // Start async module logic
        Ok(())
    }
}

Required Methods§

Source

fn name(&self) -> &str

Returns the name of the service module.

This name is used for identification, dependency resolution, and logging purposes.

Provided Methods§

Source

fn is_critical(&self) -> bool

Indicates if the module is critical to the operation of the system.

Critical modules will cause the entire system to fail if they encounter an error, while non-critical modules can fail independently.

Default: true

Source

fn priority(&self) -> i32

Returns the priority of the module.

Modules with higher priority are executed first within the same dependency level.

Default: 0

Source

fn dependencies(&self) -> Vec<&str>

Returns the list of module dependencies.

Dependencies are module names that must be initialized and started before this module. The runtime will ensure dependencies are processed in the correct order.

Default: Vec::new()

Source

fn init<'life0, 'life1, 'async_trait>( &'life0 mut self, _ctx: &'life1 mut DMSCServiceContext, ) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Initializes the service module.

This method is called during the initialization phase to set up module resources.

Default: Ok(())

Source

fn before_start<'life0, 'life1, 'async_trait>( &'life0 mut self, _ctx: &'life1 mut DMSCServiceContext, ) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Prepares the module for startup.

This method is called after initialization but before the main start phase.

Default: Ok(())

Source

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

Starts the service module.

This method is called to start the main functionality of the module.

Default: Ok(())

Source

fn after_start<'life0, 'life1, 'async_trait>( &'life0 mut self, _ctx: &'life1 mut DMSCServiceContext, ) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Performs post-startup operations.

This method is called after the main start phase but before the module is considered fully started.

Default: Ok(())

Source

fn before_shutdown<'life0, 'life1, 'async_trait>( &'life0 mut self, _ctx: &'life1 mut DMSCServiceContext, ) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Prepares the module for shutdown.

This method is called before the main shutdown phase.

Default: Ok(())

Source

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

Shuts down the service module.

This method is called to stop the main functionality of the module.

Default: Ok(())

Source

fn after_shutdown<'life0, 'life1, 'async_trait>( &'life0 mut self, _ctx: &'life1 mut DMSCServiceContext, ) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Performs post-shutdown cleanup.

This method is called after the main shutdown phase to clean up resources.

Default: Ok(())

Implementors§