1use crate::migration::MigrationConfig;
2use anyhow::Result;
3use serde::{Deserialize, Serialize};
4use std::fs;
5use std::path::Path;
6
7#[derive(Debug, Default, Clone, Serialize, Deserialize)]
9pub struct Config {
10 pub migration: MigrationConfig,
12}
13
14impl Config {
15 pub fn new() -> Self {
17 Self::default()
18 }
19
20 pub fn load() -> Result<Self> {
22 let path = Path::new("Toasty.toml");
23 let contents = fs::read_to_string(path)?;
24 let config: Config = toml::from_str(&contents)?;
25 Ok(config)
26 }
27
28 pub fn migration(mut self, migration: MigrationConfig) -> Self {
30 self.migration = migration;
31 self
32 }
33}