atelier_data 0.0.15

Data Artifacts and I/O for the atelier-rs engine
use serde::Deserialize;
use std::{error::Error, fs};
use toml;

use crate::templates::{
    exchanges::centralized::ExchangeConfig, experiments::ExpConfig,
    features::FeatureConfig,
};

/// Load exchanges config files
pub mod exchanges;
/// Load experiments config files
pub mod experiments;
/// Load features data and config files
pub mod features;

#[derive(Debug, Deserialize, Clone)]
pub struct Config {
    pub experiments: Vec<ExpConfig>,
    pub exchanges: Vec<ExchangeConfig>,
    pub features: Option<Vec<FeatureConfig>>,
}

impl Config {
    pub fn load_from_toml(file_route: &str) -> Result<Self, Box<dyn Error>> {
        let contents = fs::read_to_string(file_route)?;
        let config: Config = toml::from_str(&contents)?;
        Ok(config)
    }
}