Trait dinglebit_config::Config
source · [−]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> { ... }
}
Expand description
The main trait for this package. This should be implemented if you want to use this package with your configuration systems.
Required Methods
Provided Methods
Get the value as an integer or panics if one isn’t found or cannot be parsed.
Get the value as a float or panics if one isn’t found or cannot be parsed.
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.
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.
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.
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”].