use serde::{Deserialize, Serialize};
use std::error::Error;
use std::path::Path;
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, clap::ValueEnum)]
#[serde(rename_all = "lowercase")]
pub enum QcType {
Int,
Char,
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct CoraConfig {
pub time_var: String,
pub qc_type: QcType,
pub has_time_qc: bool,
pub has_deph_source: bool,
#[serde(default)]
pub pattern: Option<String>,
}
impl CoraConfig {
pub fn cora() -> Self {
Self {
time_var: "TIME".to_string(),
qc_type: QcType::Int,
has_time_qc: true,
has_deph_source: true,
pattern: None,
}
}
pub fn cora_legacy() -> Self {
Self {
time_var: "JULD".to_string(),
qc_type: QcType::Char,
has_time_qc: false,
has_deph_source: false,
pattern: None,
}
}
pub fn from_file(path: &Path) -> Result<Self, Box<dyn Error>> {
let content = std::fs::read_to_string(path)?;
Ok(toml::from_str(&content)?)
}
}