{{ header }}#nullable enable

using System;

namespace {{ namespace }};

/// <summary>Controls how the visitor affects the conversion pipeline.</summary>
public abstract record {{ result_type }}
{
    private {{ result_type }}() {}

{% for variant in unit_variants %}
    public sealed record {{ variant.cs_name }} : {{ result_type }};

{% endfor %}
{% for variant in payload_variants %}
    public sealed record {{ variant.cs_name }}(string {{ variant.payload_property }}) : {{ result_type }};

{% endfor %}
    internal string ToFfiJson() => this switch {
{% for variant in unit_variants %}
        {{ result_type }}.{{ variant.cs_name }} => "\"{{ variant.wire_name }}\"",
{% endfor %}
{% for variant in payload_variants %}
        {{ result_type }}.{{ variant.cs_name }} c => "{{ "{" }}\"{{ variant.wire_name }}\":" + System.Text.Json.JsonSerializer.Serialize(c.{{ variant.payload_property }}) + "{{ "}" }}",
{% endfor %}
        _ => "\"{{ default_wire_name }}\""
    };
}
