summaryrefslogtreecommitdiffstats
path: root/third_party/rust/uniffi_bindgen/src/scaffolding/templates/TopLevelFunctionTemplate.rs
blob: eeee0f5ee2972b97ebacc2bea3cbc58b93745836 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#[::uniffi::export_for_udl]
pub fn r#{{ func.name() }}(
    {%- for arg in func.arguments() %}
    r#{{ arg.name() }}: {% if arg.by_ref() %}&{% endif %}{{ arg.as_type().borrow()|type_rs }},
    {%- endfor %}
)
{%- match (func.return_type(), func.throws_type()) %}
{%- when (Some(return_type), None) %} -> {{ return_type|type_rs }}
{%- when (Some(return_type), Some(error_type)) %} -> ::std::result::Result::<{{ return_type|type_rs }}, {{ error_type|type_rs }}>
{%- when (None, Some(error_type)) %} -> ::std::result::Result::<(), {{ error_type|type_rs }}>
{%- when (None, None) %}
{%- endmatch %}
{
    unreachable!()
}