mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-27 15:40:03 +08:00
chore: rm read_json_config
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
|
||||
use std::{
|
||||
env,
|
||||
fs::{ self, File },
|
||||
io::{ Lines, BufReader },
|
||||
path::{ Path, PathBuf },
|
||||
};
|
||||
|
||||
use crate::{
|
||||
iff,
|
||||
util_os,
|
||||
@@ -118,18 +116,6 @@ pub fn find_parents_exists_dir(dir: &str) -> Option<PathBuf> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "use_serde")]
|
||||
pub fn read_json_config<T>(config: Option<String>, files: &[String]) -> XResult<Option<(PathBuf, T)>> where T: serde::de::DeserializeOwned {
|
||||
let config_path_buf_opt = read_config(config, files);
|
||||
match config_path_buf_opt {
|
||||
None => Ok(None),
|
||||
Some(config_path_buf) => {
|
||||
let json_config: T = serde_json::from_reader(std::fs::File::open(&config_path_buf)?)?;
|
||||
Ok(Some((config_path_buf, json_config)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_config(config: Option<String>, files: &[String]) -> Option<PathBuf> {
|
||||
match config {
|
||||
Some(config_str) => Some(PathBuf::from(config_str)),
|
||||
|
||||
Reference in New Issue
Block a user