1 {%- match python_config
.custom_types
.get(name
.as_str()) %}
3 {#- No custom type config, just forward all methods to our builtin type #}
5 {{ name
}} = {{ builtin|type_name
}}
7 class _UniffiConverterType
{{ name
}}:
10 {{ builtin|ffi_converter_name
}}.write(value
, buf
)
14 return {{ builtin|ffi_converter_name
}}.read(buf
)
18 return {{ builtin|ffi_converter_name
}}.lift(value
)
22 return {{ builtin|ffi_converter_name
}}.lower(value
)
24 {%- when
Some(config
) %}
26 {%- match config
.imports
%}
27 {%- when
Some(imports
) %}
28 {%- for import_name
in imports
%}
29 {{ self
.add_import(import_name
) }}
35 {{ name
}} = {{ builtin|type_name
}}
37 {#- Custom type config supplied, use it to convert the builtin type #}
38 class _UniffiConverterType
{{ name
}}:
40 def write(value
, buf
):
41 builtin_value
= {{ config
.from_custom
.render("value") }}
42 {{ builtin|write_fn
}}(builtin_value
, buf
)
46 builtin_value
= {{ builtin|read_fn
}}(buf
)
47 return {{ config
.into_custom
.render("builtin_value") }}
51 builtin_value
= {{ builtin|lift_fn
}}(value
)
52 return {{ config
.into_custom
.render("builtin_value") }}
56 builtin_value
= {{ config
.from_custom
.render("value") }}
57 return {{ builtin|lower_fn
}}(builtin_value
)