summaryrefslogtreecommitdiffstats
path: root/src/env.rs
diff options
context:
space:
mode:
authorRyan Leckey <ryan@launchbadge.com>2017-06-22 14:14:29 -0700
committerRyan Leckey <ryan@launchbadge.com>2017-06-22 14:30:51 -0700
commit2b438ed9b53fee5689032f3b5fcdda8d15becd5f (patch)
tree48374e66a6594c7d11d19fe38f7e23df731b52be /src/env.rs
parent04d3ee8f70337e4899932b92262fbeec2dbb1bd9 (diff)
Add builder API to Config
Diffstat (limited to 'src/env.rs')
-rw-r--r--src/env.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/env.rs b/src/env.rs
index a0b190b..abadea2 100644
--- a/src/env.rs
+++ b/src/env.rs
@@ -4,6 +4,7 @@ use error::*;
use source::Source;
use value::{Value, ValueKind};
+#[derive(Clone, Debug)]
pub struct Environment {
/// Optional prefix that will limit access to the environment to only keys that
/// begin with the defined prefix.
@@ -29,7 +30,10 @@ impl Environment {
}
pub fn with_prefix(s: &str) -> Self {
- Environment { prefix: Some(s.into()), ..Environment::default() }
+ Environment {
+ prefix: Some(s.into()),
+ ..Environment::default()
+ }
}
pub fn prefix(&mut self, s: String) -> &mut Self {
@@ -53,6 +57,10 @@ impl Default for Environment {
}
impl Source for Environment {
+ fn clone_into_box(&self) -> Box<Source + Send + Sync> {
+ Box::new((*self).clone())
+ }
+
fn collect(&self) -> Result<HashMap<String, Value>> {
let mut m = HashMap::new();
let uri: String = "the environment".into();
@@ -80,7 +88,8 @@ impl Source for Environment {
// Replace `separator` with `.`
key = key.replace(&self.separator, ".");
- m.insert(key.to_lowercase(), Value::new(Some(&uri), ValueKind::String(value)));
+ m.insert(key.to_lowercase(),
+ Value::new(Some(&uri), ValueKind::String(value)));
}
Ok(m)