1use std::{
2 collections::HashMap,
3 path::{Path, PathBuf},
4};
5
6#[derive(Clone)]
7pub struct Config {
8 pub options: Option<HashMap<String, String>>,
9 pub native_file: Option<PathBuf>,
10}
11
12impl Config {
13 pub fn new() -> Config {
14 Config {
15 options: None,
16 native_file: None,
17 }
18 }
19
20 pub fn options<'a>(self, options: HashMap<&'a str, &'a str>) -> Self {
21 let options = options
22 .into_iter()
23 .map(|(key, value)| (String::from(key), String::from(value)))
24 .collect::<HashMap<String, String>>();
25
26 let mut config = self;
27
28 config.options = Some(options);
29 config
30 }
31
32 pub fn native_file(self, native_file: impl AsRef<Path>) -> Self {
33 let native_file: PathBuf = native_file.as_ref().into();
34 let mut config = self;
35 config.native_file = Some(native_file);
36 config
37 }
38}