pub struct DynamicConfig { /* private fields */ }Expand description
The initializer that puts one reading on every request.
let initializers: Vec<Box<dyn Initializer>> =
vec![Box::new(DynamicConfig::new(ConfigSections::new()))];Loco calls after_routes once, with the
router it has built, and this adds the layer to it — so every route the
application declares is covered, including the ones Loco adds itself.
Implementations§
Source§impl DynamicConfig
impl DynamicConfig
Sourcepub fn new(sections: Sections) -> Self
pub fn new(sections: Sections) -> Self
Builds the initializer over the sections a request should read.
Sourcepub fn boxed(sections: Sections) -> Box<dyn Initializer>
pub fn boxed(sections: Sections) -> Box<dyn Initializer>
The same, boxed, for the Vec<Box<dyn Initializer>> Loco wants.
let initializers: Vec<Box<dyn Initializer>> =
vec![DynamicConfig::boxed(ConfigSections::new())];Sourcepub fn layer(&self) -> SnapshotLayer
pub fn layer(&self) -> SnapshotLayer
The layer this initializer installs.
For an application that already has an initializer of its own and
would rather add one layer than one more Box<dyn Initializer>:
let configuration = DynamicConfig::new(ConfigSections::new());
let router = router.layer(configuration.layer());Trait Implementations§
Source§impl Debug for DynamicConfig
impl Debug for DynamicConfig
Source§impl Initializer for DynamicConfig
impl Initializer for DynamicConfig
Source§fn after_routes<'life0, 'life1, 'async_trait>(
&'life0 self,
router: AxumRouter,
_context: &'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,
_context: &'life1 AppContext,
) -> Pin<Box<dyn Future<Output = Result<AxumRouter>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Adds the layer to the router Loco has built.
Source§fn before_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_app_context: &'life1 AppContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn before_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_app_context: &'life1 AppContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Occurs after the app’s
before_run.
Use this to for one-time initializations, load caches, perform web
hooks, etc.Source§fn check<'life0, 'life1, 'async_trait>(
&'life0 self,
_app_context: &'life1 AppContext,
) -> Pin<Box<dyn Future<Output = Result<Option<Check>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn check<'life0, 'life1, 'async_trait>(
&'life0 self,
_app_context: &'life1 AppContext,
) -> Pin<Box<dyn Future<Output = Result<Option<Check>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Perform health checks for this initializer.
This method is called during the doctor command to validate the initializer’s configuration.
Return
None if no check is needed, or Some(Check) if a check should be performed.Auto Trait Implementations§
impl !RefUnwindSafe for DynamicConfig
impl !UnwindSafe for DynamicConfig
impl Freeze for DynamicConfig
impl Send for DynamicConfig
impl Sync for DynamicConfig
impl Unpin for DynamicConfig
impl UnsafeUnpin for DynamicConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more