From 648a70110894bc5d79c65c2e4775970ddc460c0f Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 20 Sep 2025 16:25:49 +0800 Subject: Add exist function to ConfigFile trait --- crates/utils/cfg_file/src/config.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/utils/cfg_file/src/config.rs b/crates/utils/cfg_file/src/config.rs index 8d97bf0..2333ab7 100644 --- a/crates/utils/cfg_file/src/config.rs +++ b/crates/utils/cfg_file/src/config.rs @@ -193,4 +193,15 @@ pub trait ConfigFile: Serialize + for<'a> Deserialize<'a> + Default { eprintln!("Failed to write file {}: {}", path.display(), e); } } + + /// Check if the file returned by `default_path` exists + fn exist() -> bool + where + Self: Sized + Send + Sync, + { + let Ok(path) = Self::default_path() else { + return false; + }; + path.exists() + } } -- cgit