Trait dinglebit_config::Config [−][src]
pub trait Config { fn get(&self, key: &str) -> Option<String>; fn must_get(&self, key: &str) -> String { ... } fn string(&self, key: &str) -> String { ... } fn int(&self, key: &str) -> i64 { ... } fn float(&self, key: &str) -> f64 { ... } fn bool(&self, key: &str) -> bool { ... } fn duration(&self, key: &str) -> Duration { ... } fn datetime(&self, key: &str) -> DateTime<Utc> { ... } fn list(&self, key: &str) -> Vec<String> { ... } fn map(&self, key: &str) -> HashMap<String, String> { ... } }
The main trait for this package. This should be implemented if you want to use this package with your configuration systems.
Required methods
Loading content...Provided methods
fn must_get(&self, key: &str) -> String
[src]
Similar to get
but panics if there is no value.
fn string(&self, key: &str) -> String
[src]
Get the value as a string or panics if one isn’t found.
fn int(&self, key: &str) -> i64
[src]
Get the value as an integer or panics if one isn’t found or cannot be parsed.
fn float(&self, key: &str) -> f64
[src]
Get the value as a float or panics if one isn’t found or cannot be parsed.
fn bool(&self, key: &str) -> bool
[src]
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.
fn duration(&self, key: &str) -> Duration
[src]
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.
fn datetime(&self, key: &str) -> DateTime<Utc>
[src]
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.
fn list(&self, key: &str) -> Vec<String>
[src]
Get a list or panics if one isn’t found. The list should be a comma-delimited list surrouned by brackets (e.g. [1, 2, 3] => vec![“1”, “2”, “3”].
fn map(&self, key: &str) -> HashMap<String, String>
[src]
Get a map or panics if one isn’t found. The list should be a comma-delimited list surrouned by braces with key/value pairs associated with => (e.g. {a=>1, b=>2, c=>3} => ((a,1), (b,2), (c,3))).
Implementations on Foreign Types
impl Config for HashMap<&str, &str>
[src]
Loading content...Implementors
impl Config for Environment
[src]
fn get(&self, key: &str) -> Option<String>
[src]
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’.