aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/config.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/config.rs b/src/config.rs
index 881759c..d9dbe74 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -2,12 +2,12 @@ use crate::dyndns_service::DynDnsProvider;
use crate::error::{AppError, AppResult};
use crate::ip_service::IpServiceProvider;
use fqdn::FQDN;
+use log::warn;
use serde::{Deserialize, Serialize};
use serde_with::DisplayFromStr;
use serde_with::serde_as;
-use std::path::{Path, PathBuf};
+use std::path::PathBuf;
use std::{fs, io};
-use log::warn;
use strum::Display;
#[derive(Debug, Deserialize, Serialize)]
@@ -20,20 +20,20 @@ impl Config {
pub fn load(paths: Vec<PathBuf>) -> AppResult<Config> {
let mut index = 1;
for path in &paths {
- let content = fs::read_to_string(&path);
+ let content = fs::read_to_string(path);
match content {
- Ok(value) => {
- match serde_json::from_str(&value) {
- Ok(config) => { return Ok(config) },
- Err(error) => {
- if index == paths.len() { return Err(AppError::ConfigParseError {
+ Ok(value) => match serde_json::from_str(&value) {
+ Ok(config) => return Ok(config),
+ Err(error) => {
+ if index == paths.len() {
+ return Err(AppError::ConfigParseError {
source: error,
path: path.to_path_buf(),
- })}
- warn!("{}", error);
+ });
}
+ warn!("{}", error);
}
- }
+ },
Err(e) => {
let error = match e.kind() {
io::ErrorKind::NotFound => AppError::ConfigFileNotFound(path.clone()),
@@ -43,7 +43,7 @@ impl Config {
return Err(error);
}
warn!("{}", error);
- },
+ }
}
index += 1;
}
@@ -98,7 +98,7 @@ mod tests {
};
use serde_json::json;
use std::fs::read_dir;
- use std::path::PathBuf;
+ use std::path::{Path, PathBuf};
use std::str::FromStr;
test! {