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
impl EnvConfigSource
Sourcepub fn new() -> Self
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.
Sourcepub fn with_prefix(prefix: &str) -> Self
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.
Sourcepub fn with_options(
prefix: &str,
strip_prefix: bool,
convert_underscores: bool,
lowercase_keys: bool,
) -> Self
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 bystrip_prefix- Whether to strip the prefix from the keyconvert_underscores- Whether to convert underscores to dotslowercase_keys- Whether to lowercase the key
§Returns
A configured EnvConfigSource.
Trait Implementations§
Source§impl Clone for EnvConfigSource
impl Clone for EnvConfigSource
Source§fn clone(&self) -> EnvConfigSource
fn clone(&self) -> EnvConfigSource
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl ConfigSource for EnvConfigSource
impl ConfigSource for EnvConfigSource
Source§impl Debug for EnvConfigSource
impl Debug for EnvConfigSource
Auto Trait Implementations§
impl Freeze for EnvConfigSource
impl RefUnwindSafe for EnvConfigSource
impl Send for EnvConfigSource
impl Sync for EnvConfigSource
impl Unpin for EnvConfigSource
impl UnsafeUnpin for EnvConfigSource
impl UnwindSafe for EnvConfigSource
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
Mutably borrows from an owned value. Read more