use serde::{Deserialize, Serialize};
use std::error::Error;
use std::path::Path;
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct NrtConfig {
pub has_deph_source: bool,
pub has_profile_coords: bool,
#[serde(default)]
pub pattern: Option<String>,
}
impl NrtConfig {
pub fn nrt_ar() -> Self {
Self { has_deph_source: false, has_profile_coords: false, pattern: None }
}
pub fn nrt_bo() -> Self {
Self { has_deph_source: true, has_profile_coords: true, pattern: None }
}
pub fn nrt_mo() -> Self {
Self { has_deph_source: false, has_profile_coords: false, pattern: None }
}
pub fn nrt_gl() -> Self {
Self { has_deph_source: true, has_profile_coords: 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)?)
}
}