use crate::error::{RailResult, ResultExt};
use std::path::Path;
use toml_edit::DocumentMut;
pub fn read_toml_file(path: &Path) -> RailResult<DocumentMut> {
let content = std::fs::read_to_string(path).with_context(|| format!("Failed to read {}", path.display()))?;
content
.parse()
.with_context(|| format!("Failed to parse {}", path.display()))
}
pub fn write_toml_file(path: &Path, doc: &DocumentMut) -> RailResult<()> {
std::fs::write(path, doc.to_string()).with_context(|| format!("Failed to write {}", path.display()))
}