#[derive(serde::Deserialize, Default)]
#[serde(default)]
pub struct {{ input_name }} {
{%- for field in fields %}
    #[serde(rename = "{{ field.serde_rename }}")]
    pub {{ field.name }}: {{ field.ty }},
{%- endfor %}
}

impl From<{{ input_name }}> for {{ core_path }} {
    fn from(val: {{ input_name }}) -> Self {
{%- if has_default %}
        let mut out = Self::default();
{%- for field in fields %}
        if let Some(v) = val.{{ field.name }} {
            out.{{ field.core_name }} = {{ field.conv }};
        }
{%- endfor %}
        out
{%- else %}
        Self {
{%- for field in fields %}
            {{ field.core_name }}: val.{{ field.name }}.map(|v| {{ field.conv }}).unwrap_or_default(),
{%- endfor %}
        }
{%- endif %}
    }
}
