blob: e2cada9a65cc04da89757b4dc67f83c1c557edd3 [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.
*/}}
{{- define "ResultDeclaration" }}
{{ if .ErrType -}}
pub type {{ .Name }} = Result<(
{{- if gt (len .Ok) 1 }}
{{- range $ok := .Ok }}
{{ $ok.Type }},
{{- end }}
{{- else }}
{{- range $ok := .Ok }}
{{ $ok.Type }}
{{- end }}
{{- end }}
), {{ .ErrType }} >;
/// Handle-type validating wrapper for {{ .Name }} responses, used internally by
/// FIDL bindings to decode method results. This should only be used by
/// generated APIs, API users should never need to use this type. It is public
/// because it is shared with composed protocols.
#[doc(hidden)]
pub type {{ .Name }}HandleWrapper = Result< (
{{- range $ok := .Ok }}
{{ if $ok.HasHandleMetadata }}
{{ $ok.HandleWrapperName }}<{{ $ok.Type }}>,
{{ else }}
{{ $ok.Type }},
{{ end }}
{{- end }}
), {{ .ErrType }} >;
{{- end }}
{{ if .HasTransportError -}}
/// Request message decoding format for {{ .Name }} responses, used internally
/// by FIDL bindings to decode flexible method results. This should only be used
/// by generated APIs, API users should never need to use this type. It is
/// public because it is shared with composed protocols.
#[doc(hidden)]
pub type {{ .Name }}WireHandleWrapper = fidl::encoding::OpenResult< (
{{- range $ok := .Ok }}
{{ if $ok.HasHandleMetadata }}
{{ $ok.HandleWrapperName }}<{{ $ok.Type }}>,
{{ else }}
{{ $ok.Type }},
{{ end }}
{{- end }}
), {{ if .ErrType }}{{ .ErrType }}{{ else }}(){{ end }} >;
{{- end }}
{{- end }}