Debian Codegraph @

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

raw
1 #[::uniffi::export_for_udl(callback_interface)]
2 pub trait r#{{ cbi.name() }} {
3 {%- for meth in cbi.methods() %}
4 fn r#{{ meth.name() }}(
5 {% if meth.takes_self_by_arc()%}self: Arc<Self>{% else %}&self{% endif %},
6 {%- for arg in meth.arguments() %}
7 r#{{ arg.name() }}: {% if arg.by_ref() %}&{% endif %}{{ arg.as_type().borrow()|type_rs }},
8 {%- endfor %}
9 )
10 {%- match (meth.return_type(), meth.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 {% endfor %}
17 }