reactive_graph/tooling/instances/config/
serde.rs1use serde::Serialize;
2use serde::de::DeserializeOwned;
3use std::fs;
4use std::fs::read_to_string;
5use std::path::PathBuf;
6
7pub fn read_config_file<T: DeserializeOwned>(path: &PathBuf) -> anyhow::Result<T> {
8 let contents = read_to_string(path)?;
9 Ok(toml::from_str(&contents)?)
10}
11
12pub fn write_config_file<T: Serialize>(path: &PathBuf, config: T) -> anyhow::Result<()> {
13 let contents = toml::to_string_pretty(&config)?;
14 Ok(fs::write(path, contents)?)
15}