use super::FormatConfig;
use crate::codegen::{CodeConfig, StructConfig};
use zamm_yin::tao::archetype::ArchetypeTrait;
use zamm_yin::tao::relation::attribute::{OwnerArchetype, ValueArchetype};
pub const OWNER_FORM_KEY: &str = "_owner_form";
pub const VALUE_FORM_KEY: &str = "_value_form";
#[derive(Default)]
pub struct AttributeFormatConfig {
pub tao_cfg: FormatConfig,
pub owner_type: StructConfig,
pub owner_form: StructConfig,
pub value_type: StructConfig,
pub value_form: StructConfig,
}
impl<'a> From<&'a CodeConfig<'a>> for AttributeFormatConfig {
fn from(cfg: &CodeConfig) -> Self {
Self {
tao_cfg: FormatConfig::from(cfg),
owner_type: cfg.attribute_structs[OwnerArchetype::TYPE_NAME].clone(),
owner_form: cfg.attribute_structs[OWNER_FORM_KEY].clone(),
value_type: cfg.attribute_structs[ValueArchetype::TYPE_NAME].clone(),
value_form: cfg.attribute_structs[VALUE_FORM_KEY].clone(),
}
}
}