Skip to main content

save_inferred

Function save_inferred 

Source
pub fn save_inferred<P, T>(path: P, config: T) -> Result<()>
where P: AsRef<Path>, T: Serialize,
Expand description

Save the current config by inferring the format from the file extension.

.toml writes TOML. .json and .jsonc write standard JSON.

use cloudiful_config::save_inferred;
use serde::Serialize;

#[derive(Serialize)]
struct AppConfig {
    debug: bool,
}

let path = std::env::temp_dir().join("config-crate-save-inferred.jsonc");
save_inferred(&path, AppConfig { debug: true }).unwrap();