use crate::migration::MigrationConfig;
use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::fs;
use std::path::Path;
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct Config {
pub migration: MigrationConfig,
}
impl Config {
pub fn new() -> Self {
Self::default()
}
pub fn load() -> Result<Self> {
let path = Path::new("Toasty.toml");
let contents = fs::read_to_string(path)?;
let config: Config = toml::from_str(&contents)?;
Ok(config)
}
pub fn migration(mut self, migration: MigrationConfig) -> Self {
self.migration = migration;
self
}
}