pub struct AppBuilder { /* private fields */ }Expand description
AppBuilder: Application under construction The application consists of three important parts:
- Plugin management
- Component management
- Configuration management
Implementations§
Source§impl AppBuilder
impl AppBuilder
Sourcepub fn add_plugin<T: Plugin>(&mut self, plugin: T) -> &mut Self
pub fn add_plugin<T: Plugin>(&mut self, plugin: T) -> &mut Self
add plugin
Sourcepub fn is_plugin_added<T: Plugin>(&self) -> bool
pub fn is_plugin_added<T: Plugin>(&self) -> bool
Returns true if the Plugin has already been added.
Sourcepub fn use_config_file(&mut self, config_path: &str) -> &mut Self
pub fn use_config_file(&mut self, config_path: &str) -> &mut Self
The path of the configuration file, default is ./config/app.toml.
The application automatically reads the environment configuration file
in the same directory according to the SPRING_ENV environment variable,
such as ./config/app-dev.toml.
The environment configuration file has a higher priority and will
overwrite the configuration items of the main configuration file.
For specific supported environments, see the Env enum.
Sourcepub fn use_config_str(&mut self, toml_content: &str) -> &mut Self
pub fn use_config_str(&mut self, toml_content: &str) -> &mut Self
Use an existing toml string to configure the application. For example, use include_str!(‘app.toml’) to compile the file into the program.
Note: This configuration method only supports one configuration content and does not support multiple environments.
Sourcepub fn add_component<T>(&mut self, component: T) -> &mut Self
pub fn add_component<T>(&mut self, component: T) -> &mut Self
Add component to the registry
Sourcepub fn get_component_ref<T>(&self) -> Option<ComponentRef<T>>
pub fn get_component_ref<T>(&self) -> Option<ComponentRef<T>>
Get the component of the specified type
Sourcepub fn get_component<T>(&self) -> Option<T>
pub fn get_component<T>(&self) -> Option<T>
get cloned component
Sourcepub fn add_scheduler<T>(&mut self, scheduler: T) -> &mut Self
pub fn add_scheduler<T>(&mut self, scheduler: T) -> &mut Self
Add a scheduled task
Sourcepub fn add_shutdown_hook<T>(&mut self, hook: T) -> &mut Self
pub fn add_shutdown_hook<T>(&mut self, hook: T) -> &mut Self
Add a shutdown hook
Trait Implementations§
Source§impl ConfigRegistry for AppBuilder
impl ConfigRegistry for AppBuilder
Source§fn get_config<T>(&self) -> Result<T>where
T: DeserializeOwned + Configurable,
fn get_config<T>(&self) -> Result<T>where
T: DeserializeOwned + Configurable,
config_prefix