pub trait ConfigSource {
// Required method
fn load(&self, config: &mut Config) -> ConfigResult<()>;
// Provided method
fn load_into(&self, config: &mut Config) -> ConfigResult<()> { ... }
}Expand description
Trait for configuration sources
Implementors of this trait can load configuration data and populate a
Config object.
§Examples
use qubit_config::{Config, source::ConfigSource};
struct MySource;
impl ConfigSource for MySource {
fn load(&self, config: &mut Config) -> qubit_config::ConfigResult<()> {
config.set("key", "value")?;
Ok(())
}
}Required Methods§
Provided Methods§
Sourcefn load_into(&self, config: &mut Config) -> ConfigResult<()>
fn load_into(&self, config: &mut Config) -> ConfigResult<()>
Loads configuration data into an already-staged Config object.
Built-in sources override this method to avoid cloning when the caller
has already staged a transaction. Custom implementations can rely on
the default, which delegates to Self::load.
§Parameters
config- The staged configuration object to populate
§Returns
Returns Ok(()) on success, or a ConfigError on failure
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".