pub struct Environment { /* private fields */ }Implementations§
Source§impl Environment
impl Environment
Sourcepub fn new(prefix: &str) -> Self
pub fn new(prefix: &str) -> Self
Create a new environment configuration which will prefix keys with the given prefix and an underscore (e.g. prefix = “foo” => “foo_*”). An empty prefix will not prepend anything.
Getting a value from the environment will try to make the key more environment-variable-like . ‘.’ and ‘/’ are replaced with ‘_’ and everything is upper-cased. If the prefix is ‘foo’, then a get for ‘my.app.secret’ would look for ‘FOO_MY_APP_SECRET’.
Trait Implementations§
Source§impl Config for Environment
impl Config for Environment
Source§fn get(&self, key: &str) -> Option<String>
fn get(&self, key: &str) -> Option<String>
Get a value from the environment using the given key. ‘.’ and ‘/’ are replaced with ‘_’ and everything is upper-cased. If the prefix is ‘foo’, then a get for ‘my.app.secret’ would look for ‘FOO_MY_APP_SECRET’.
Source§fn int(&self, key: &str) -> i64
fn int(&self, key: &str) -> i64
Get the value as an integer or panics if one isn’t found or
cannot be parsed.
Source§fn float(&self, key: &str) -> f64
fn float(&self, key: &str) -> f64
Get the value as a float or panics if one isn’t found or
cannot be parsed.
Source§fn bool(&self, key: &str) -> bool
fn bool(&self, key: &str) -> bool
Get the value as a bool or panics if one isn’t found or cannot
be parsed. The following case-insensitive values are considered
true: t, true, 1, y, yes. All other values are considered
false.
Source§fn duration(&self, key: &str) -> Duration
fn duration(&self, key: &str) -> Duration
Get the value as a duration or panics if one isn’t found or
can’t be parsed. Thre doesn’t appear to be a parsing function
for a duration, so it attempts to convert to an integer and use
that as the number of seconds.
Source§fn datetime(&self, key: &str) -> DateTime<Utc>
fn datetime(&self, key: &str) -> DateTime<Utc>
Get the value as a duration or panics if one isn’t found or it
can’t be parsed. It uses RFC339 to parse it.
Source§impl Debug for Environment
impl Debug for Environment
Source§impl PartialEq for Environment
impl PartialEq for Environment
impl StructuralPartialEq for Environment
Auto Trait Implementations§
impl Freeze for Environment
impl RefUnwindSafe for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl UnwindSafe for Environment
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