refactor: impl as struct methods

This commit is contained in:
GyDi
2022-01-05 02:00:59 +08:00
parent c29eadd9ee
commit 3550aa10ba
8 changed files with 290 additions and 201 deletions

View File

@@ -1,5 +1,5 @@
use crate::{
config::{ClashController, ProfilesConfig, VergeConfig},
config::{ClashController, VergeConfig},
utils::app_home_dir,
};
use serde::{de::DeserializeOwned, Serialize};
@@ -103,20 +103,6 @@ pub fn read_clash_controller() -> ClashController {
}
}
/// Get Profiles Config
pub fn read_profiles() -> ProfilesConfig {
read_yaml::<ProfilesConfig>(app_home_dir().join("profiles.yaml"))
}
/// Save Verge App Config
pub fn save_profiles(profiles: &ProfilesConfig) -> Result<(), String> {
save_yaml(
app_home_dir().join("profiles.yaml"),
profiles,
Some("# Profiles Config for Clash Verge\n\n"),
)
}
/// Get the `verge.yaml`
pub fn read_verge() -> VergeConfig {
read_yaml::<VergeConfig>(app_home_dir().join("verge.yaml"))