feat: refactor

This commit is contained in:
GyDi
2022-08-12 03:20:55 +08:00
parent 178fd8e828
commit 7f6dac4271
22 changed files with 320 additions and 778 deletions

View File

@@ -87,9 +87,6 @@ pub struct Clash {
/// some info
pub info: ClashInfo,
/// save the running config
pub running_config: Option<String>,
}
impl Clash {
@@ -97,11 +94,7 @@ impl Clash {
let config = Clash::read_config();
let info = ClashInfo::from(&config);
Clash {
config,
info,
running_config: None,
}
Clash { config, info }
}
/// get clash config
@@ -118,14 +111,6 @@ impl Clash {
)
}
/// save running config
pub fn set_running_config(&mut self, config: &Mapping) {
self.running_config = match serde_yaml::to_string(config) {
Ok(config_str) => Some(config_str),
Err(_) => None,
};
}
/// patch update the clash config
/// if the port is changed then return true
pub fn patch_config(&mut self, patch: Mapping) -> Result<(bool, bool)> {