pub struct ConfigReader<'a> {
pub(crate) store: &'a ConfigStore,
pub(crate) shell: &'a Mutex<Shell>,
pub(crate) env: &'a Env,
pub(crate) unstable_advanced_env: bool,
}Expand description
Reads configuration values from the loaded store and the environment.
Fields§
§store: &'a ConfigStore§shell: &'a Mutex<Shell>§env: &'a Env§unstable_advanced_env: boolImplementations§
Source§impl<'a> ConfigReader<'a>
impl<'a> ConfigReader<'a>
pub fn new(shell: &'a Mutex<Shell>) -> Self
pub fn config(self, store: &'a ConfigStore) -> Self
pub fn env(self, env: &'a Env) -> Self
pub fn unstable_advanced_env(self, yes: bool) -> Self
Sourcepub fn get<'de, T: Deserialize<'de>>(self, key: ConfigKey) -> Result<T>
pub fn get<'de, T: Deserialize<'de>>(self, key: ConfigKey) -> Result<T>
Deserialize the value at key into T
When reading env variables, the type will be inferred from T.
When T cannot provide a type hint (e.g. #[serde(untagged)]),
the type will be inferred from the structure of the env variable.
Source§impl ConfigReader<'_>
Lower-level accessors
impl ConfigReader<'_>
Lower-level accessors
Sourcepub fn get_cv_with_env(&self, key: &ConfigKey) -> Result<Option<CV>>
pub fn get_cv_with_env(&self, key: &ConfigKey) -> Result<Option<CV>>
Read a raw value, including from the environment
When reading env variables, the type will be inferred from the structure of the env variable.
Sourcepub fn get_table(
&self,
key: &ConfigKey,
) -> Result<OptValue<HashMap<String, CV>>>
pub fn get_table( &self, key: &ConfigKey, ) -> Result<OptValue<HashMap<String, CV>>>
Low-level method for getting a config value as an OptValue<HashMap<String, CV>>.
NOTE: This does not read from env. The caller is responsible for that.
Sourcepub(crate) fn get_integer(
&self,
key: &ConfigKey,
) -> Result<OptValue<i64>, ConfigError>
pub(crate) fn get_integer( &self, key: &ConfigKey, ) -> Result<OptValue<i64>, ConfigError>
Low-level private method for getting a config value as an OptValue.
Sourcepub(crate) fn get_bool(
&self,
key: &ConfigKey,
) -> Result<OptValue<bool>, ConfigError>
pub(crate) fn get_bool( &self, key: &ConfigKey, ) -> Result<OptValue<bool>, ConfigError>
Low-level private method for getting a config value as an OptValue.
Sourcepub(crate) fn get_string_priv(
&self,
key: &ConfigKey,
) -> Result<OptValue<String>, ConfigError>
pub(crate) fn get_string_priv( &self, key: &ConfigKey, ) -> Result<OptValue<String>, ConfigError>
Low-level private method for getting a config value as an OptValue.
Sourcepub(crate) fn has_key(
&self,
key: &ConfigKey,
env_prefix_ok: bool,
) -> Result<bool>
pub(crate) fn has_key( &self, key: &ConfigKey, env_prefix_ok: bool, ) -> Result<bool>
Check if the configuration contains a given ConfigKey.
See ConfigMapAccess for a description of env_prefix_ok.
Sourcepub(crate) fn get_env_list(
&self,
key: &ConfigKey,
output: &mut Vec<ConfigValue>,
) -> Result<()>
pub(crate) fn get_env_list( &self, key: &ConfigKey, output: &mut Vec<ConfigValue>, ) -> Result<()>
Internal method for getting an environment variable as a list. If the key is a non-mergeable list and a value is found in the environment, existing values are cleared.
pub(crate) fn warn(&self, message: String) -> Result<()>
fn get_config_env<T>(&self, key: &ConfigKey) -> Result<OptValue<T>, ConfigError>
fn check_environment_key_case_mismatch(&self, key: &ConfigKey)
Trait Implementations§
Source§impl<'a> Clone for ConfigReader<'a>
impl<'a> Clone for ConfigReader<'a>
impl<'a> Copy for ConfigReader<'a>
Auto Trait Implementations§
impl<'a> Forget for ConfigReader<'a>
impl<'a> Freeze for ConfigReader<'a>
impl<'a> Move for ConfigReader<'a>
impl<'a> RefUnwindSafe for ConfigReader<'a>
impl<'a> Send for ConfigReader<'a>
impl<'a> Sync for ConfigReader<'a>
impl<'a> Unpin for ConfigReader<'a>
impl<'a> UnsafeUnpin for ConfigReader<'a>
impl<'a> UnwindSafe for ConfigReader<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes