alef 0.23.15

Opinionated polyglot binding generator for Rust libraries
Documentation
// {{ context_type }} carries context information passed to every visitor callback.
// It is decoded from the JSON-encoded context string passed by the C layer.
type {{ context_type }} struct {
{% for field in context_fields %}
{% if field.doc %}
	// {{ field.go_name }} {{ field.doc }}
{% endif %}
	{{ field.go_name }} {{ field.go_type }} `json:"{{ field.json_name }}"`
{% endfor %}
}

// {{ result_type }} controls conversion flow from a visitor callback.
type {{ result_type }} struct {
	// Code is the numeric result code following the configured Rust enum variant order.
	Code int32
	// Value is non-nil for single-payload result variants.
	Value *string
}

{% for variant in result_variants %}
{% if variant.has_payload %}
// {{ variant.helper_name }} returns a {{ variant.name }} {{ result_type }}.
func {{ variant.helper_name }}({{ variant.payload_go_name }} string) {{ result_type }} {
	return {{ result_type }}{Code: {{ variant.code }}, Value: &{{ variant.payload_go_name }}}
}
{% else %}
// {{ variant.helper_name }} returns a {{ variant.name }} {{ result_type }}.
func {{ variant.helper_name }}() {{ result_type }} {
	return {{ result_type }}{Code: {{ variant.code }}}
}
{% endif %}
{% endfor %}