blob: 6476db0a1080d7ac79190e5a53d2500145db09ed [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package codegen
const unionTmpl = `
{{- define "UnionDeclaration" }}
{{- range .DocComments}}
///{{ . }}
{{- end}}
{{ .Derives }}
pub enum {{ .Name }} {
{{- range .Members }}
{{- range .DocComments }}
///{{ . }}
{{- end }}
{{ .Name }}({{ .Type }}),
{{- end }}
{{- if not .Strictness }}
#[doc(hidden)]
__UnknownVariant {
ordinal: u64,
bytes: Vec<u8>,
handles: Vec<fidl::Handle>,
},
{{- end }}
}
fidl_xunion! {
name: {{ .Name }},
members: [
{{- range .Members }}
{{ .Name }} {
ty: {{ .Type }},
ordinal: {{ .Ordinal }},
{{- if .HasHandleMetadata }}
handle_metadata: {
handle_subtype: {{ .HandleSubtype }},
handle_rights: {{ .HandleRights }},
},
{{- end }}
},
{{- end }}
],
{{- if not .Strictness }}
unknown_member: __UnknownVariant,
{{- end }}
}
{{- end }}
`