Skip to main content

Module

Trait Module 

Source
pub trait Module: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn version(&self) -> &'static str;
    fn configure_routes<'life0, 'async_trait>(
        &'life0 self,
        router: Router,
    ) -> Pin<Box<dyn Future<Output = Router> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn configure_services<'life0, 'life1, 'async_trait>(
        &'life0 self,
        container: &'life1 mut ServiceContainer,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn initialize<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ModuleResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn shutdown<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ModuleResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Trait that all business modules must implement

This trait defines the contract for modules in the Backbone Framework, enabling modular composition and lifecycle management.

Required Methods§

Source

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

Returns the name of the module

Source

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

Returns the version of the module

Source

fn configure_routes<'life0, 'async_trait>( &'life0 self, router: Router, ) -> Pin<Box<dyn Future<Output = Router> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Configures routes for this module

§Arguments
  • router - The Axum router to configure routes on
§Returns

The configured router with module-specific routes added

Source

fn configure_services<'life0, 'life1, 'async_trait>( &'life0 self, container: &'life1 mut ServiceContainer, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Configures services in the dependency injection container

§Arguments
  • container - The service container to register services in
Source

fn initialize<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ModuleResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initializes the module

This is called after all services are configured and before the module starts serving requests. Use this for any setup work that needs to be done.

Source

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

Shuts down the module

This is called when the application is shutting down. Use this for cleanup work.

Provided Methods§

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Performs a health check for this module

§Returns

true if the module is healthy, false otherwise

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§