{{- /*gotype: go.mau.fi/mautrix-telegram/pkg/gotd/gen.structDef*/ -}}
{{ define "struct" }}{{ $s := . }}
// {{ $s.Comment }}
{{- if $s.Docs }}
{{- template "print_comment"  $s.Docs }}
{{- end }}
{{- if $s.Links }}
    {{- template "print_links" $s.Links }}
{{- end }}
{{- if $s.URL }}
//
// See {{ $s.URL }} for reference.
{{- end }}
type {{ $s.Name }} struct {
{{- range $f := $s.Fields }}
{{- template "print_comment" $f.Comment }}
{{- if $f.Links}}
    {{- template "print_links" $f.Links }}
{{- end }}
{{- if and ($f.Conditional) (not $f.ConditionalBool) }}
//
// Use Set{{ $f.Name }} and Get{{ $f.Name }} helpers.
{{- end }}
    {{ $f.Name }} {{ template "print_type" $f }}
{{- end }}
}

// {{ $s.Name }}TypeID is TL type id of {{ $s.Name }}.
const {{ $s.Name }}TypeID = {{ if not $s.Vector }}0x{{ $s.HexID }}{{- else -}}bin.TypeVector{{- end }}

{{ if $s.Interface }}
// construct implements constructor of {{ $s.Interface }}.
func ({{ $s.Receiver }} {{ $s.Name }}) construct() {{ $s.Interface }} { return &{{ $s.Receiver }} }
{{ end }}

// Ensuring interfaces in compile-time for {{ $s.Name }}.
var (
    _ bin.Encoder = &{{ $s.Name }}{}
    _ bin.Decoder = &{{ $s.Name }}{}
    _ bin.BareEncoder = &{{ $s.Name }}{}
    _ bin.BareDecoder = &{{ $s.Name }}{}
    {{ if $s.Interface }}
    _ {{ $s.Interface }} = &{{ $s.Name }}{}
    {{ end }}
)
{{ end }}
