1#[cfg(feature = "cli")]
6pub mod cli;
7mod load;
8
9use std::{fs, io, path::PathBuf};
10
11use schemars::JsonSchema;
12use serde::{Serialize, de::DeserializeOwned};
13
14pub use load::{LoadConfigError, try_load};
15pub use schemars;
16
17pub trait ConfigFile: Default + DeserializeOwned + Serialize + JsonSchema {
19 fn config_file_path() -> PathBuf;
21
22 fn delete(&self) -> io::Result<()> {
24 fs::remove_file(Self::config_file_path())
25 }
26
27 fn write(&self) -> io::Result<()> {
29 let json = serde_json::to_string_pretty(self).map_err(io::Error::other)?;
30 fs::write(Self::config_file_path(), json)
31 }
32}