Trait schematic::PartialConfig
source · pub trait PartialConfig: Clone + Default + DeserializeOwned + Schematic + Serialize + Sized {
type Context: Default;
// Required methods
fn default_values(
context: &Self::Context
) -> Result<Option<Self>, ConfigError>;
fn env_values() -> Result<Option<Self>, ConfigError>;
fn extends_from(&self) -> Option<ExtendsFrom>;
fn finalize(self, context: &Self::Context) -> Result<Self, ConfigError>;
fn merge(
&mut self,
context: &Self::Context,
next: Self
) -> Result<(), ConfigError>;
// Provided method
fn validate(
&self,
context: &Self::Context,
finalize: bool
) -> Result<(), ValidatorError> { ... }
}Expand description
Required Associated Types§
Required Methods§
sourcefn default_values(context: &Self::Context) -> Result<Option<Self>, ConfigError>
fn default_values(context: &Self::Context) -> Result<Option<Self>, ConfigError>
Return a partial configuration with values populated with default values for settings
marked with #[setting(default)]. Unmarked settings will be None.
If a default value fails to parse or cast into the correct type, an error is returned.
sourcefn env_values() -> Result<Option<Self>, ConfigError>
fn env_values() -> Result<Option<Self>, ConfigError>
Return a partial configuration with values populated from environment variables
for settings marked with #[setting(env)]. Unmarked settings will be None.
If an environment variable does not exist, the value will be None. If
the variable fails to parse or cast into the correct type, an error is returned.
sourcefn extends_from(&self) -> Option<ExtendsFrom>
fn extends_from(&self) -> Option<ExtendsFrom>
When a setting is marked as extendable with #[setting(extend)], this returns
ExtendsFrom with the extended sources, either a list of strings or a single string.
When no setting is extendable, this returns None.
sourcefn finalize(self, context: &Self::Context) -> Result<Self, ConfigError>
fn finalize(self, context: &Self::Context) -> Result<Self, ConfigError>
Finalize the partial configuration by consuming it and populating all fields with a value.
Defaults values from PartialConfig::default_values will be applied first, followed
by merging the current partial, and lastly environment variable values from
PartialConfig::env_values.