Skip to content

Commit 48443ec

Browse files
authored
Update with config constructor to still read config files first (#119)
1 parent c740242 commit 48443ec

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

rust/src/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl Client {
158158

159159
pub fn new_with_config(url: &str, config: HashMap<String, String>) -> Result<Self> {
160160
let parsed_url = Url::parse(url)?;
161-
Self::with_config(&parsed_url, Configuration::from(config))
161+
Self::with_config(&parsed_url, Configuration::new_with_config(config)?)
162162
}
163163

164164
fn with_config(url: &Url, config: Configuration) -> Result<Self> {

rust/src/common/config.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ pub struct Configuration {
2121
map: HashMap<String, String>,
2222
}
2323

24-
impl From<HashMap<String, String>> for Configuration {
25-
fn from(conf_map: HashMap<String, String>) -> Self {
26-
Self { map: conf_map }
27-
}
28-
}
29-
3024
impl Configuration {
3125
pub fn new() -> io::Result<Self> {
3226
let mut map: HashMap<String, String> = HashMap::new();
@@ -47,6 +41,12 @@ impl Configuration {
4741
Ok(Configuration { map })
4842
}
4943

44+
pub fn new_with_config(conf_map: HashMap<String, String>) -> io::Result<Self> {
45+
let mut conf = Self::new()?;
46+
conf.map.extend(conf_map);
47+
Ok(conf)
48+
}
49+
5050
/// Get a value from the config, returning None if the key wasn't defined.
5151
pub fn get(&self, key: &str) -> Option<String> {
5252
self.map.get(key).cloned()

0 commit comments

Comments
 (0)