Debian Codegraph @

third_party/rust/uniffi_bindgen/src/scaffolding/templates/TopLevelFunctionTemplate.rs

raw
1 {#
2 // Forward work to `uniffi_macros` This keeps macro-based and UDL-based generated code consistent.
3 #}
4 #[::uniffi::export_for_udl]
5 pub {% if func.is_async() %}async {% endif %}fn r#{{ func.name() }}(
6 {%- for arg in func.arguments() %}
7 r#{{ arg.name() }}: {% if arg.by_ref() %}&{% endif %}{{ arg.as_type().borrow()|type_rs }},
8 {%- endfor %}
9 )
10 {%- match (func.return_type(), func.throws_type()) %}
11 {%- when (Some(return_type), None) %} -> {{ return_type|type_rs }}
12 {%- when (Some(return_type), Some(error_type)) %} -> ::std::result::Result::<{{ return_type|type_rs }}, {{ error_type|type_rs }}>
13 {%- when (None, Some(error_type)) %} -> ::std::result::Result::<(), {{ error_type|type_rs }}>
14 {%- when (None, None) %}
15 {%- endmatch %}
16 {
17 unreachable!()
18 }