pub struct EnvSource<'a> { /* private fields */ }
Available on crate feature
env
only.Expand description
A Source
referring to environment variables.
Uses the envious crate for interpreting env vars.
§Examples
use confik::{ConfigBuilder, Configuration, EnvSource};
#[derive(Configuration)]
struct Config {
port: u16,
}
std::env::set_var("PORT", "1234");
let config = ConfigBuilder::<Config>::default()
.override_with(EnvSource::new())
.try_build()
.unwrap();
assert_eq!(config.port, 1234);
Implementations§
source§impl<'a> EnvSource<'a>
impl<'a> EnvSource<'a>
sourcepub fn with_prefix(self, prefix: &'a str) -> Self
pub fn with_prefix(self, prefix: &'a str) -> Self
Sets the envious prefix.
sourcepub fn with_separator(self, separator: &'a str) -> Self
pub fn with_separator(self, separator: &'a str) -> Self
Sets the envious separator.
sourcepub fn with_config(self, config: Config<'a>) -> Self
pub fn with_config(self, config: Config<'a>) -> Self
Sets the envious config.
sourcepub fn allow_secrets(self) -> Self
pub fn allow_secrets(self) -> Self
Allows this source to contain secrets.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for EnvSource<'a>
impl<'a> RefUnwindSafe for EnvSource<'a>
impl<'a> Send for EnvSource<'a>
impl<'a> Sync for EnvSource<'a>
impl<'a> Unpin for EnvSource<'a>
impl<'a> UnwindSafe for EnvSource<'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
Mutably borrows from an owned value. Read more