ines_core/project/
config.rs1use crate::project::error::Result;
2
3use serde::{Deserialize, Serialize};
4use std::path::PathBuf;
5
6#[derive(Debug, Serialize, Deserialize)]
7pub struct Config {
8 pub version: usize,
9 pub out: PathBuf,
10 pub generate_redirects: Option<Vec<String>>,
11}
12
13impl Config {
14 pub fn from_file(path: &PathBuf) -> Result<Self> {
15 let content = std::fs::read_to_string(path)?;
16 toml::from_str(&content).map_err(Into::into)
17 }
18
19 pub fn write_to_file(&self, path: &PathBuf) -> Result<()> {
20 std::fs::write(path, toml::to_string_pretty(self)?).map_err(Into::into)
21 }
22}
23
24impl Default for Config {
25 fn default() -> Self {
26 Self {
27 version: 0,
28 out: PathBuf::from("out"),
29 generate_redirects: None,
30 }
31 }
32}