pub struct ConfBuilder<S, F = fn(&dyn ConfigEvent)>{ /* private fields */ }Expand description
A builder which collects config value sources and other options, before parsing your struct.
- Use any of
ConfBuilder::args,ConfBuilder::env,ConfBuilder::docto set sources - If desired, use
ConfBuilder::config_loggerto set a callback and trackValueSource’s - Use one of
ConfBuilder::parseorConfBuilder::try_parseto try to parse your struct.
If args is not set, the default source is std::env::args_os.
If env is not set, the default source is std::env::vars_os.
Implementations§
Source§impl<S, F> ConfBuilder<S, F>
impl<S, F> ConfBuilder<S, F>
Sourcepub fn args(self, args: impl IntoIterator<Item: Into<OsString>>) -> Self
pub fn args(self, args: impl IntoIterator<Item: Into<OsString>>) -> Self
Set the CLI args used in this parse
Sourcepub fn env<K, V>(self, env: impl IntoIterator<Item = (K, V)>) -> Self
pub fn env<K, V>(self, env: impl IntoIterator<Item = (K, V)>) -> Self
Set the env vars used in this parse
Sourcepub fn config_logger<F2: FnMut(&dyn ConfigEvent)>(
self,
f: F2,
) -> ConfBuilder<S, F2>
pub fn config_logger<F2: FnMut(&dyn ConfigEvent)>( self, f: F2, ) -> ConfBuilder<S, F2>
Set the config logger used in this parse This enables introspection on the config process, so that it can be determined which program options are configured via which value sources.
Source§impl<S, F> ConfBuilder<S, F>
impl<S, F> ConfBuilder<S, F>
Sourcepub fn doc<'de, D: Deserializer<'de>>(
self,
document_name: impl Into<String>,
deserializer: D,
) -> ConfSerdeBuilder<'de, D, S, F>
pub fn doc<'de, D: Deserializer<'de>>( self, document_name: impl Into<String>, deserializer: D, ) -> ConfSerdeBuilder<'de, D, S, F>
Set the document used in this parse.
Requires a name for the document and a serde Deserializer representing the content.
The name is typically the name of a file, and is used in error messages.
The deserializer is, for example, a serde_json::Value, serde_yaml::Value, figment::Value, etc. which you have already loaded from disk and parsed in an unstructured way.