{%- if fields.is_empty() %}
{{ self::kdoc_block(doc, "") }}object {{ class_name }} {
    fun decode(reader: WireReader): {{ class_name }} = {{ class_name }}

    fun wireEncodedSize(): Int = 0

    fun wireEncodeTo(wire: WireWriter) {
    }
}
{%- else %}
{{ self::kdoc_block(doc, "") }}data class {{ class_name }}(
{%- for field in fields %}
{{ self::kdoc_block(field.doc, "    ") }}    val {{ field.name }}: {{ field.kotlin_type }}{% if field.has_default() %} = {{ field.default_expr() }}{% endif %}{% if !loop.last %},{% endif %}
{%- endfor %}
) {
    companion object {
{%- if is_blittable %}
        const val SIZE_BYTES: Int = {{ struct_size }}

        fun decode(reader: WireReader): {{ class_name }} = {{ class_name }}(
{%- for field in fields %}
            {{ field.wire_decode_expr }}{% if is_blittable && field.padding_after > 0 %}.also { reader.skip({{ field.padding_after }}) }{% endif %}{% if !loop.last %},{% endif %}
{%- endfor %}
        )
{%- else %}
        fun decode(reader: WireReader): {{ class_name }} = {{ class_name }}(
{%- for field in fields %}
            {{ field.wire_decode_expr }}{% if !loop.last %},{% endif %}
{%- endfor %}
        )
{%- endif %}
    }

{%- if is_blittable %}
    fun wireEncodedSize(): Int = SIZE_BYTES
{%- else %}
    fun wireEncodedSize(): Int =
{%- for field in fields %}
        {{ field.wire_size_expr }}{% if !loop.last %} +{% endif %}
{%- endfor %}
{%- endif %}

    fun wireEncodeTo(wire: WireWriter) {
{%- for field in fields %}
        {{ field.wire_encode }}
{%- if is_blittable && field.padding_after > 0 %}
        wire.writePadding({{ field.padding_after }})
{%- endif %}
{%- endfor %}
    }
}
{%- endif %}
