2021-09-11 18:21:34 +00:00
|
|
|
pub mod format;
|
2021-10-09 16:05:32 +00:00
|
|
|
mod printers;
|
2021-09-11 18:21:34 +00:00
|
|
|
|
|
|
|
use crate::formatter::format::Format;
|
|
|
|
use serde::Deserialize;
|
|
|
|
use std::fs::File;
|
|
|
|
use std::io::Read;
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
|
|
|
pub struct FormatConfig {
|
|
|
|
pub formats: Vec<Format>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FormatConfig {
|
|
|
|
pub fn new(config_path: &Path) -> Result<Self, std::io::Error> {
|
|
|
|
let mut config = File::open(config_path)?;
|
|
|
|
|
|
|
|
let mut contents = String::new();
|
|
|
|
|
|
|
|
config.read_to_string(&mut contents)?;
|
|
|
|
|
|
|
|
Ok(toml::from_str(&contents).unwrap())
|
|
|
|
}
|
|
|
|
}
|