pub struct ApplicationContextBuilder { /* private fields */ }Expand description
Application context builder
ApplicationContextBuilder provides a fluent API for constructing
an ApplicationContext with various configuration sources, profiles,
and settings.
§Examples
use verdure_context::ApplicationContextBuilder;
let context = ApplicationContextBuilder::new()
.with_property("app.name", "MyApp")
.build()
.unwrap();Implementations§
Source§impl ApplicationContextBuilder
impl ApplicationContextBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new application context builder
§Examples
use verdure_context::ApplicationContextBuilder;
let builder = ApplicationContextBuilder::new();Sourcepub fn with_config_source(self, source: ConfigSource) -> Self
pub fn with_config_source(self, source: ConfigSource) -> Self
Sourcepub fn with_toml_config_file<P: AsRef<Path>>(self, path: P) -> Self
pub fn with_toml_config_file<P: AsRef<Path>>(self, path: P) -> Self
Sourcepub fn with_yaml_config_file<P: AsRef<Path>>(self, path: P) -> Self
pub fn with_yaml_config_file<P: AsRef<Path>>(self, path: P) -> Self
Sourcepub fn with_properties_config_file<P: AsRef<Path>>(self, path: P) -> Self
pub fn with_properties_config_file<P: AsRef<Path>>(self, path: P) -> Self
Sourcepub fn with_config_file<P: AsRef<Path>>(self, path: P) -> Self
pub fn with_config_file<P: AsRef<Path>>(self, path: P) -> Self
Loads configuration from a file with automatic format detection
The format is detected based on the file extension:
.toml-> TOML format.yamlor.yml-> YAML format.properties-> Properties format- Others -> Attempts to parse as TOML first, then YAML, then Properties
§Arguments
path- Path to the configuration file
§Examples
use verdure_context::ApplicationContextBuilder;
let builder = ApplicationContextBuilder::new()
.with_config_file("config/app.yaml")
.with_config_file("config/database.properties")
.with_config_file("config/server.toml");Sourcepub fn build(self) -> ContextResult<ApplicationContext>
pub fn build(self) -> ContextResult<ApplicationContext>
Builds the application context
§Returns
A new ApplicationContext instance configured with the specified settings
§Errors
Returns an error if context initialization fails
§Examples
use verdure_context::ApplicationContextBuilder;
let context = ApplicationContextBuilder::new()
.with_property("app.name", "MyApp")
.build()
.unwrap();Trait Implementations§
Source§impl Debug for ApplicationContextBuilder
impl Debug for ApplicationContextBuilder
Auto Trait Implementations§
impl Freeze for ApplicationContextBuilder
impl RefUnwindSafe for ApplicationContextBuilder
impl Send for ApplicationContextBuilder
impl Sync for ApplicationContextBuilder
impl Unpin for ApplicationContextBuilder
impl UnsafeUnpin for ApplicationContextBuilder
impl UnwindSafe for ApplicationContextBuilder
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