alef 0.30.5

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{# Per-variant constructor on a flat data enum. Builds the CORE variant then converts to the flat PHP
   struct via the generated `From<core::Enum>` impl (`.into()`), reusing the same param/let-binding
   machinery method bodies use. Exposed to PHP under the snake name; Rust fn is `_factory_<snake>` to
   avoid colliding with the variant's `get_<flat>` accessor. A `Vec<NamedStruct>` field can fail to
   decode, forcing a `PhpResult<Self>` return. #}
#[php(name = "{{ php_name }}")]
{% if fallible -%}
pub fn {{ rust_fn_name }}({{ params }}) -> PhpResult<Self> {
    {{ let_bindings }}Ok({{ core_variant }}.into())
}
{%- else -%}
pub fn {{ rust_fn_name }}({{ params }}) -> Self {
    {{ let_bindings }}{{ core_variant }}.into()
}
{%- endif %}