Skip to main content

EnvConfigSource

Struct EnvConfigSource 

Source
pub struct EnvConfigSource { /* private fields */ }
Expand description

Configuration source that loads from system environment variables

§Examples

use qubit_config::source::{EnvConfigSource, ConfigSource};
use qubit_config::Config;

// Load all env vars
let source = EnvConfigSource::new();

// Load only vars with prefix "APP_", strip prefix and normalize key
let source = EnvConfigSource::with_prefix("APP_");

let mut config = Config::new();
source.load(&mut config).unwrap();

§Author

Haixing Hu

Implementations§

Source§

impl EnvConfigSource

Source

pub fn new() -> Self

Creates a new EnvConfigSource that loads all environment variables.

Keys are loaded as-is (no prefix filtering, no transformation).

§Returns

A source that ingests every std::env::vars() entry.

Source

pub fn with_prefix(prefix: &str) -> Self

Creates a new EnvConfigSource that filters by prefix and normalizes keys.

Only variables with the given prefix are loaded. The prefix is stripped, the key is lowercased, and underscores are converted to dots.

§Parameters
  • prefix - The prefix to filter by (e.g., "APP_")
§Returns

A source with prefix filtering and key normalization enabled.

Source

pub fn with_options( prefix: &str, strip_prefix: bool, convert_underscores: bool, lowercase_keys: bool, ) -> Self

Creates a new EnvConfigSource with a custom prefix and explicit options.

§Parameters
  • prefix - The prefix to filter by
  • strip_prefix - Whether to strip the prefix from the key
  • convert_underscores - Whether to convert underscores to dots
  • lowercase_keys - Whether to lowercase the key
§Returns

A configured EnvConfigSource.

Trait Implementations§

Source§

impl Clone for EnvConfigSource

Source§

fn clone(&self) -> EnvConfigSource

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl ConfigSource for EnvConfigSource

Source§

fn load(&self, config: &mut Config) -> ConfigResult<()>

Loads configuration data into the provided Config object Read more
Source§

impl Debug for EnvConfigSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EnvConfigSource

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.

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.

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.