Skip to main content

ConfigReader

Struct ConfigReader 

Source
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: bool

Implementations§

Source§

impl<'a> ConfigReader<'a>

Source

pub fn new(shell: &'a Mutex<Shell>) -> Self

Source

pub fn config(self, store: &'a ConfigStore) -> Self

Source

pub fn env(self, env: &'a Env) -> Self

Source

pub fn unstable_advanced_env(self, yes: bool) -> Self

Source

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

Source

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.

Source

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.

Source

pub(crate) fn get_integer( &self, key: &ConfigKey, ) -> Result<OptValue<i64>, ConfigError>

Low-level private method for getting a config value as an OptValue.

Source

pub(crate) fn get_bool( &self, key: &ConfigKey, ) -> Result<OptValue<bool>, ConfigError>

Low-level private method for getting a config value as an OptValue.

Source

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.

Source

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.

Source

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.

Source

pub(crate) fn warn(&self, message: String) -> Result<()>

Source

fn get_config_env<T>(&self, key: &ConfigKey) -> Result<OptValue<T>, ConfigError>
where T: FromStr, <T as FromStr>::Err: Display,

Source

fn check_environment_key_case_mismatch(&self, key: &ConfigKey)

Trait Implementations§

Source§

impl<'a> Clone for ConfigReader<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for ConfigReader<'a>

Auto Trait Implementations§

§

impl<'a> Forget for ConfigReader<'a>

§

impl<'a> Freeze for ConfigReader<'a>
where &'a ConfigStore: Freeze, &'a Mutex<Shell>: Freeze, &'a Env: Freeze,

§

impl<'a> Move for ConfigReader<'a>

§

impl<'a> RefUnwindSafe for ConfigReader<'a>

§

impl<'a> Send for ConfigReader<'a>
where &'a ConfigStore: Send, &'a Mutex<Shell>: Send, &'a Env: Send,

§

impl<'a> Sync for ConfigReader<'a>

§

impl<'a> Unpin for ConfigReader<'a>
where &'a ConfigStore: Unpin, &'a Mutex<Shell>: Unpin, &'a Env: Unpin,

§

impl<'a> UnsafeUnpin for ConfigReader<'a>

§

impl<'a> UnwindSafe for ConfigReader<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

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