+impl Config {
+ fn default() -> Self {
+ Config { smtp_login: "login".to_string(), smtp_password: "password".to_string() }
+ }
+
+ fn read(file_path: &str) -> Result<Config> {
+ match File::open(file_path) {
+ Ok(file) => from_reader(file).map_err(|e| e.into()),
+ Err(_) => {
+ let file = File::create(file_path)?;
+ let default_config = Config::default();
+ to_writer(file, &default_config)?;
+ Ok(default_config)
+ }
+ }
+ }
+}
+