use super::*;
mod der;
#[derive(Debug, Clone, Default, Serialize)]
pub struct TableConfig {
pub line: TableLineMode,
pub typing: TypeMetaInfo,
pub unity: UnityCodegen,
}
#[derive(Copy, Clone, Debug, Serialize)]
pub struct TableLineMode {
pub typing: usize,
pub field: usize,
pub helper: usize,
pub data: usize,
}
impl TableConfig {
pub fn load_file(path: Option<&Path>, global: Option<&ProjectConfig>) -> XResult<Self> {
let basic = match global {
Some(s) => TableConfig::from(s),
None => Default::default(),
};
let _: Option<()> = try {
let text = read_to_string(path?).ok()?;
let table = text.parse::<Value>().ok()?;
if let Ok(o) = table.deserialize_any(basic.clone()) {
return Ok(o);
}
};
Ok(basic)
}
}
impl From<&ProjectConfig> for TableConfig {
fn from(project: &ProjectConfig) -> Self {
TableConfig { line: project.line, typing: project.typing.clone(), unity: project.unity.clone() }
}
}