| {{/* |
| // Copyright 2021 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 "Method:Result:WireMessagingHeader" }} |
| {{- EnsureNamespace "" }} |
| |
| {{ if .WireResultUnwrapType -}} |
| template<> |
| struct {{ .WireResultUnwrap }} { |
| using Type = {{ .WireResultUnwrapType }}; |
| }; |
| {{- end }} |
| |
| template<> |
| class [[nodiscard]] {{ .WireResult }} final : public {{ .BaseWireResult }} { |
| public: |
| {{ .WireResult.Self }}( |
| {{ .Protocol.UnownedClientEnd }} client, |
| {{ .WireTransactionalRequest }}* request |
| ); |
| |
| explicit {{ .WireResult.Self }}(const ::fidl::Status& result) : {{ .BaseWireResult }}(result) {} |
| {{ .WireResult.Self }}({{ .WireResult.Self }}&&) = delete; |
| {{ .WireResult.Self }}(const {{ .WireResult.Self }}&) = delete; |
| {{ .WireResult.Self }}& operator=({{ .WireResult.Self }}&&) = delete; |
| {{ .WireResult.Self }}& operator=(const {{ .WireResult.Self }}&) = delete; |
| ~{{ .WireResult.Self }}() = default; |
| |
| {{- if .HasResponse }} |
| private: |
| {{ .Response.ClientAllocationV1.BackingBufferType }} bytes_; |
| {{- if .HasResponsePayload }} |
| ::fidl::DecodedValue<{{ .WireResponse }}> decoded_; |
| {{- end }} |
| {{- end }} |
| }; |
| |
| {{- end }} |
| |
| |
| |
| {{- define "Method:Result:WireMessagingSource" }} |
| {{- IfdefFuchsia -}} |
| {{- EnsureNamespace "" }} |
| {{ .WireResult }}::{{ .WireResult.Self }}( |
| {{ .Protocol.UnownedClientEnd }} client, |
| {{ .WireTransactionalRequest }}* request |
| ) { |
| FIDL_INTERNAL_DISABLE_AUTO_VAR_INIT |
| ::fidl::internal::OwnedEncodedMessage<{{ .WireTransactionalRequest }}, {{ .Transport.Type }}> request_message( |
| ::fidl::internal::AllowUnownedInputRef{}, request); |
| auto& outgoing = request_message.GetOutgoingMessage(); |
| |
| {{- if .HasResponse }} |
| {{ .IncomingMessageHandleStorageForResponse }} handle_storage; |
| ::fit::result decoded = ::fidl::internal::InplaceDecodeTransactionalResponse<{{ .Marker }}>( |
| outgoing.Call(client.handle(), handle_storage.view(bytes_.view()), fidl::CallOptions{}) |
| ); |
| SetStatus(::fidl::internal::StatusFromResult(decoded)); |
| {{- if .HasResponsePayload }} |
| if (ok()) { |
| decoded_ = std::move(decoded.value()); |
| ExtractValueFromDecoded(decoded_.pointer()); |
| } |
| {{- end }} |
| {{- else }} |
| outgoing.Write(client.handle()); |
| SetStatus(outgoing); |
| {{- end }} |
| } |
| |
| {{- EndifFuchsia -}} |
| {{- end }} |