Debian Codegraph @

third_party/rust/uniffi_bindgen/src/bindings/python/templates/TopLevelFunctionTemplate.py

raw
1 {%- if func.is_async() %}
2
3 {%- match func.return_type() -%}
4 {%- when Some(return_type) %}
5 async def {{ func.name() }}({%- call py::arg_list_decl(func) -%}) -> "{{ return_type|type_name }}":
6 {% when None %}
7 async def {{ func.name() }}({%- call py::arg_list_decl(func) -%}) -> None:
8 {% endmatch %}
9
10 {%- call py::docstring(func, 4) %}
11 {%- call py::setup_args(func) %}
12 return await _uniffi_rust_call_async(
13 _UniffiLib.{{ func.ffi_func().name() }}({% call py::arg_list_lowered(func) %}),
14 _UniffiLib.{{func.ffi_rust_future_poll(ci) }},
15 _UniffiLib.{{func.ffi_rust_future_complete(ci) }},
16 _UniffiLib.{{func.ffi_rust_future_free(ci) }},
17 # lift function
18 {%- match func.return_type() %}
19 {%- when Some(return_type) %}
20 {{ return_type|lift_fn }},
21 {%- when None %}
22 lambda val: None,
23 {% endmatch %}
24 {% call py::error_ffi_converter(func) %}
25 )
26
27 {%- else %}
28 {%- match func.return_type() -%}
29 {%- when Some(return_type) %}
30
31 def {{ func.name() }}({%- call py::arg_list_decl(func) -%}) -> "{{ return_type|type_name }}":
32 {%- call py::docstring(func, 4) %}
33 {%- call py::setup_args(func) %}
34 return {{ return_type|lift_fn }}({% call py::to_ffi_call(func) %})
35 {% when None %}
36
37 def {{ func.name() }}({%- call py::arg_list_decl(func) -%}) -> None:
38 {%- call py::docstring(func, 4) %}
39 {%- call py::setup_args(func) %}
40 {% call py::to_ffi_call(func) %}
41 {% endmatch %}
42 {%- endif %}