pub trait Config {
// Required method
fn get(&self, key: &str) -> Option<String>;
// Provided methods
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§
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.
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.
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.
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.
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.