Lines Matching +full:convert +full:- +full:source +full:- +full:map
4 use crate::map::Map;
5 use crate::source::Source;
15 /// to be part of the source environment.
43 /// Alternate source for the environment. This can be used when you want to test your own code
44 /// using this source, without the need to change the actual system environment variables.
52 /// # use std::convert::TryInto;
55 /// fn test_config() -> Result<(), config::ConfigError> {
61 /// let source = Environment::default()
62 /// .source(Some({
64 /// env.insert("MY_STRING".into(), "my-value".into());
69 /// .add_source(source)
72 /// assert_eq!(config.my_string, "my-value");
77 source: Option<Map<String, String>>, field
82 pub fn new() -> Self { in new()
86 pub fn with_prefix(s: &str) -> Self { in with_prefix()
93 pub fn prefix(mut self, s: &str) -> Self { in prefix()
98 pub fn prefix_separator(mut self, s: &str) -> Self { in prefix_separator()
103 pub fn separator(mut self, s: &str) -> Self { in separator()
110 pub fn list_separator(mut self, s: &str) -> Self { in list_separator()
118 pub fn with_list_parse_key(mut self, key: &str) -> Self { in with_list_parse_key()
122 self.list_parse_keys = self.list_parse_keys.map(|mut keys| { in with_list_parse_key()
130 pub fn ignore_empty(mut self, ignore: bool) -> Self { in ignore_empty()
137 pub fn try_parsing(mut self, try_parsing: bool) -> Self { in try_parsing()
142 pub fn keep_prefix(mut self, keep: bool) -> Self { in keep_prefix()
147 pub fn source(mut self, source: Option<Map<String, String>>) -> Self { in source() method
148 self.source = source; in source()
153 impl Source for Environment {
154 fn clone_into_box(&self) -> Box<dyn Source + Send + Sync> { in clone_into_box()
158 fn collect(&self) -> Result<Map<String, Value>> { in collect()
159 let mut m = Map::new(); in collect()
173 .map(|prefix| format!("{}{}", prefix, prefix_separator).to_lowercase()); in collect()
202 // convert to lowercase because bool parsing expects all lowercase in collect()
214 .map(|s| Value::new(Some(&uri), ValueKind::String(s.to_string()))) in collect()
223 .map(|s| Value::new(Some(&uri), ValueKind::String(s.to_string()))) in collect()
237 match &self.source { in collect()
238 Some(source) => source.clone().into_iter().for_each(collector), in collect()