Struct dinglebit_config::env::Environment
source · [−]pub struct Environment { /* private fields */ }
Implementations
sourceimpl 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
sourceimpl Config for Environment
impl Config for Environment
sourcefn 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’.
sourcefn 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. Read more
sourcefn 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. Read more
sourcefn 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. Read more
sourcefn 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. Read more
sourcefn 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. Read more
sourceimpl Debug for Environment
impl Debug for Environment
sourceimpl PartialEq<Environment> for Environment
impl PartialEq<Environment> for Environment
sourcefn eq(&self, other: &Environment) -> bool
fn eq(&self, other: &Environment) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Environment) -> bool
fn ne(&self, other: &Environment) -> bool
This method tests for !=
.
impl StructuralPartialEq for Environment
Auto Trait Implementations
impl RefUnwindSafe for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl UnwindSafe for Environment
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more