alef 0.79.4

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
{# from_json bridge fns stay unconditional for an ordinary (field/variant-gated) type -- see #}
{# rust_mirror_enum_attribute.jinja for that rationale. This one names `core_ty` (the host #}
{# path) directly in its body, so when the WHOLE type is gated (`source_cfg` from `ty.cfg`) #}
{# the function must carry the same gate or it references a path that does not exist in a #}
{# build excluding that feature. #}
{% if source_cfg %}#[cfg({{ source_cfg }})]
{% endif %}#[frb]
pub fn {{ fn_name }}(json: String) -> Result<{{ type_name }}, String> {
    serde_json::from_str::<{{ core_ty }}>(&json)
        .map_err(|e| e.to_string())
        .and_then({{ conversion }})
}