pub trait Initializer<S>: Send{
// Required methods
fn name(&self) -> String;
fn enabled(&self, state: &S) -> bool;
fn priority(&self, state: &S) -> i32;
// Provided methods
fn after_router(&self, router: Router, _state: &S) -> RoadsterResult<Router> { ... }
fn before_middleware(
&self,
router: Router,
_state: &S,
) -> RoadsterResult<Router> { ... }
fn after_middleware(
&self,
router: Router,
_state: &S,
) -> RoadsterResult<Router> { ... }
fn before_serve(&self, router: Router, _state: &S) -> RoadsterResult<Router> { ... }
}Expand description
Provides hooks into various stages of the app’s startup to allow initializing and installing anything that needs to be done during a specific stage of startup of the HTTP service.
Required Methods§
fn name(&self) -> String
fn enabled(&self, state: &S) -> bool
Sourcefn priority(&self, state: &S) -> i32
fn priority(&self, state: &S) -> i32
Used to determine the order in which the initializer will run during app initialization.
Smaller numbers will run before larger numbers. For example, an initializer with priority
-10 will run before an initializer with priority 10.
If two initializers have the same priority, they are not guaranteed to run in any particular order relative to each other. This may be fine for many initializers.
If the order in which your initializer runs doesn’t particularly matter, it’s generally
safe to set its priority as 0.
Provided Methods§
fn after_router(&self, router: Router, _state: &S) -> RoadsterResult<Router>
fn before_middleware( &self, router: Router, _state: &S, ) -> RoadsterResult<Router>
fn after_middleware(&self, router: Router, _state: &S) -> RoadsterResult<Router>
fn before_serve(&self, router: Router, _state: &S) -> RoadsterResult<Router>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".