Bug 1941128 - Turn off network.dns.native_https_query on Mac again
[gecko.git] / dom / canvas / ParamTraits_TiedFields.h
blob288a6d13da55eab9ae03c49ffaf7f5696464d898
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef MOZILLA_PARAMTRAITS_TIEDFIELDS_H
7 #define MOZILLA_PARAMTRAITS_TIEDFIELDS_H
9 #include "ipc/IPCMessageUtils.h"
10 #include "mozilla/ipc/IPDLParamTraits.h"
11 #include "TiedFields.h"
13 namespace IPC {
15 template <class T>
16 struct ParamTraits_TiedFields {
17 static_assert(mozilla::AssertTiedFieldsAreExhaustive<T>());
19 static void Write(MessageWriter* const writer, const T& in) {
20 const auto& fields = mozilla::TiedFields(in);
21 mozilla::MapTuple(fields, [&](const auto& field) {
22 WriteParam(writer, field);
23 return true; // ignored
24 });
27 static bool Read(MessageReader* const reader, T* const out) {
28 const auto& fields = mozilla::TiedFields(*out);
29 bool ok = true;
30 mozilla::MapTuple(fields, [&](auto& field) {
31 if (ok) {
32 ok &= ReadParam(reader, &field);
34 return true; // ignored
35 });
36 return ok;
40 // -
42 template <class U, size_t N>
43 struct ParamTraits<mozilla::PaddingField<U, N>> final
44 : public ParamTraits_TiedFields<mozilla::PaddingField<U, N>> {};
46 } // namespace IPC
48 #endif