pub trait Initializer: Sync + Send {
// Required method
fn name(&self) -> String;
// Provided methods
fn before_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_app_context: &'life1 AppContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn after_routes<'life0, 'life1, 'async_trait>(
&'life0 self,
router: AxumRouter,
_ctx: &'life1 AppContext,
) -> Pin<Box<dyn Future<Output = Result<AxumRouter>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
An initializer.
Initializers should be kept in src/initializers/
Required Methods§
Provided Methods§
Sourcefn before_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_app_context: &'life1 AppContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_app_context: &'life1 AppContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Occurs after the app’s before_run.
Use this to for one-time initializations, load caches, perform web
hooks, etc.
Sourcefn after_routes<'life0, 'life1, 'async_trait>(
&'life0 self,
router: AxumRouter,
_ctx: &'life1 AppContext,
) -> Pin<Box<dyn Future<Output = Result<AxumRouter>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_routes<'life0, 'life1, 'async_trait>(
&'life0 self,
router: AxumRouter,
_ctx: &'life1 AppContext,
) -> Pin<Box<dyn Future<Output = Result<AxumRouter>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Occurs after the app’s after_routes.
Use this to compose additional functionality and wire it into an Axum
Router