//
// Automatically generated by ipdlc.
// Edit at your own risk
//


#include "mozilla/net/PDNSRequestParams.h"

#include "ipc/IPCMessageUtils.h"
#include "ipc/IPCMessageUtilsSpecializations.h"
#include "nsIFile.h"
#include "mozilla/ipc/Endpoint.h"
#include "mozilla/ipc/ProtocolMessageUtils.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/ipc/ShmemMessageUtils.h"
#include "mozilla/ipc/TaintingIPCUtils.h"


//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |struct DNSRecord|
//
namespace mozilla {
namespace net {
auto DNSRecord::StaticAssertions() const -> void
{
    static_assert(
        (offsetof(DNSRecord, trrFetchDurationNetworkOnly_) - offsetof(DNSRecord, trrFetchDuration_)) == 8,
        "Bad assumptions about field layout!");
}

} // namespace net
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::net::DNSRecord>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).canonicalName());
    // Sentinel = 'canonicalName'
    (aWriter)->WriteSentinel(612828458);
    IPC::WriteParam(aWriter, (aVar).addrs());
    // Sentinel = 'addrs'
    (aWriter)->WriteSentinel(100467215);
    IPC::WriteParam(aWriter, (aVar).isTRR());
    // Sentinel = 'isTRR'
    (aWriter)->WriteSentinel(97518037);
    IPC::WriteParam(aWriter, (aVar).effectiveTRRMode());
    // Sentinel = 'effectiveTRRMode'
    (aWriter)->WriteSentinel(899089967);
    IPC::WriteParam(aWriter, (aVar).lastUpdate());
    // Sentinel = 'lastUpdate'
    (aWriter)->WriteSentinel(379388952);
    (aWriter)->WriteBytes((&((aVar).trrFetchDuration())), 16);
    // Sentinel = 'trrFetchDuration | trrFetchDurationNetworkOnly'
    (aWriter)->WriteSentinel(2859340377);
    (aWriter)->WriteBytes((&((aVar).ttl())), 4);
    // Sentinel = 'ttl'
    (aWriter)->WriteSentinel(45285717);
}

auto ParamTraits<::mozilla::net::DNSRecord>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe___canonicalName = IPC::ReadParam<::nsCString>(aReader);
    if (!maybe___canonicalName) {
        aReader->FatalError("Error deserializing 'canonicalName' (nsCString) member of 'DNSRecord'");
        return {};

    }
    auto& _canonicalName = *maybe___canonicalName;
    // Sentinel = 'canonicalName'
    if ((!((aReader)->ReadSentinel(612828458)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'canonicalName' (nsCString) member of 'DNSRecord'");
        return {};
    }
    auto maybe___addrs = IPC::ReadParam<nsTArray<::mozilla::net::NetAddr>>(aReader);
    if (!maybe___addrs) {
        aReader->FatalError("Error deserializing 'addrs' (NetAddr[]) member of 'DNSRecord'");
        return {};

    }
    auto& _addrs = *maybe___addrs;
    // Sentinel = 'addrs'
    if ((!((aReader)->ReadSentinel(100467215)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'addrs' (NetAddr[]) member of 'DNSRecord'");
        return {};
    }
    auto maybe___isTRR = IPC::ReadParam<bool>(aReader);
    if (!maybe___isTRR) {
        aReader->FatalError("Error deserializing 'isTRR' (bool) member of 'DNSRecord'");
        return {};

    }
    auto& _isTRR = *maybe___isTRR;
    // Sentinel = 'isTRR'
    if ((!((aReader)->ReadSentinel(97518037)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'isTRR' (bool) member of 'DNSRecord'");
        return {};
    }
    auto maybe___effectiveTRRMode = IPC::ReadParam<::nsIRequest::TRRMode>(aReader);
    if (!maybe___effectiveTRRMode) {
        aReader->FatalError("Error deserializing 'effectiveTRRMode' (TRRMode) member of 'DNSRecord'");
        return {};

    }
    auto& _effectiveTRRMode = *maybe___effectiveTRRMode;
    // Sentinel = 'effectiveTRRMode'
    if ((!((aReader)->ReadSentinel(899089967)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'effectiveTRRMode' (TRRMode) member of 'DNSRecord'");
        return {};
    }
    auto maybe___lastUpdate = IPC::ReadParam<::mozilla::TimeStamp>(aReader);
    if (!maybe___lastUpdate) {
        aReader->FatalError("Error deserializing 'lastUpdate' (TimeStamp) member of 'DNSRecord'");
        return {};

    }
    auto& _lastUpdate = *maybe___lastUpdate;
    // Sentinel = 'lastUpdate'
    if ((!((aReader)->ReadSentinel(379388952)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'lastUpdate' (TimeStamp) member of 'DNSRecord'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_canonicalName),
            std::move(_addrs),
            double{0},
            double{0},
            std::move(_isTRR),
            std::move(_effectiveTRRMode),
            ::uint32_t{0},
            std::move(_lastUpdate)};
    if ((!((aReader)->ReadBytesInto((&((result__)->trrFetchDuration())), 16)))) {
        aReader->FatalError("Error bulk reading fields from double");
        return {};
    }
    // Sentinel = 'trrFetchDuration | trrFetchDurationNetworkOnly'
    if ((!((aReader)->ReadSentinel(2859340377)))) {
        mozilla::ipc::SentinelReadError("Error bulk reading fields from double");
        return {};
    }
    if ((!((aReader)->ReadBytesInto((&((result__)->ttl())), 4)))) {
        aReader->FatalError("Error bulk reading fields from uint32_t");
        return {};
    }
    // Sentinel = 'ttl'
    if ((!((aReader)->ReadSentinel(45285717)))) {
        mozilla::ipc::SentinelReadError("Error bulk reading fields from uint32_t");
        return {};
    }
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |union DNSRequestResponse|
//
namespace mozilla {
namespace net {
auto DNSRequestResponse::MaybeDestroy() -> void
{
    if ((mType) == (T__None)) {
        return;
    }
    switch (mType) {
    case TDNSRecord:
        {
            (ptr_DNSRecord())->~DNSRecord__tdef();
            break;
        }
    case TIPCTypeRecord:
        {
            (ptr_IPCTypeRecord())->~IPCTypeRecord__tdef();
            break;
        }
    case Tnsresult:
        {
            (ptr_nsresult())->~nsresult__tdef();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("not reached");
            break;
        }
    }
}

MOZ_IMPLICIT DNSRequestResponse::DNSRequestResponse(const DNSRecord& aOther)
{
    new (mozilla::KnownNotNull, ptr_DNSRecord()) DNSRecord(aOther);
    mType = TDNSRecord;
}

MOZ_IMPLICIT DNSRequestResponse::DNSRequestResponse(DNSRecord&& aOther)
{
    new (mozilla::KnownNotNull, ptr_DNSRecord()) DNSRecord(std::move(aOther));
    mType = TDNSRecord;
}

MOZ_IMPLICIT DNSRequestResponse::DNSRequestResponse(const IPCTypeRecord& aOther)
{
    new (mozilla::KnownNotNull, ptr_IPCTypeRecord()) IPCTypeRecord(aOther);
    mType = TIPCTypeRecord;
}

MOZ_IMPLICIT DNSRequestResponse::DNSRequestResponse(IPCTypeRecord&& aOther)
{
    new (mozilla::KnownNotNull, ptr_IPCTypeRecord()) IPCTypeRecord(std::move(aOther));
    mType = TIPCTypeRecord;
}

MOZ_IMPLICIT DNSRequestResponse::DNSRequestResponse(const nsresult& aOther)
{
    new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(aOther);
    mType = Tnsresult;
}

MOZ_IMPLICIT DNSRequestResponse::DNSRequestResponse(nsresult&& aOther)
{
    new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(std::move(aOther));
    mType = Tnsresult;
}

MOZ_IMPLICIT DNSRequestResponse::DNSRequestResponse(const DNSRequestResponse& aOther)
{
    (aOther).AssertSanity();
    switch ((aOther).type()) {
    case TDNSRecord:
        {
            new (mozilla::KnownNotNull, ptr_DNSRecord()) DNSRecord((aOther).get_DNSRecord());
            break;
        }
    case TIPCTypeRecord:
        {
            new (mozilla::KnownNotNull, ptr_IPCTypeRecord()) IPCTypeRecord((aOther).get_IPCTypeRecord());
            break;
        }
    case Tnsresult:
        {
            new (mozilla::KnownNotNull, ptr_nsresult()) nsresult((aOther).get_nsresult());
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    mType = (aOther).type();
}

MOZ_IMPLICIT DNSRequestResponse::DNSRequestResponse(DNSRequestResponse&& aOther)
{
    (aOther).AssertSanity();
    Type t = (aOther).type();
    switch (t) {
    case TDNSRecord:
        {
            new (mozilla::KnownNotNull, ptr_DNSRecord()) DNSRecord(std::move((aOther).get_DNSRecord()));
            (aOther).MaybeDestroy();
            break;
        }
    case TIPCTypeRecord:
        {
            new (mozilla::KnownNotNull, ptr_IPCTypeRecord()) IPCTypeRecord(std::move((aOther).get_IPCTypeRecord()));
            (aOther).MaybeDestroy();
            break;
        }
    case Tnsresult:
        {
            new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(std::move((aOther).get_nsresult()));
            (aOther).MaybeDestroy();
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    (aOther).mType = T__None;
    mType = t;
}

DNSRequestResponse::~DNSRequestResponse()
{
    MaybeDestroy();
}

auto DNSRequestResponse::operator=(const DNSRecord& aRhs) -> DNSRequestResponse&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_DNSRecord()) DNSRecord(aRhs);
    mType = TDNSRecord;
    return (*(this));
}

auto DNSRequestResponse::operator=(DNSRecord&& aRhs) -> DNSRequestResponse&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_DNSRecord()) DNSRecord(std::move(aRhs));
    mType = TDNSRecord;
    return (*(this));
}

auto DNSRequestResponse::operator=(const IPCTypeRecord& aRhs) -> DNSRequestResponse&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_IPCTypeRecord()) IPCTypeRecord(aRhs);
    mType = TIPCTypeRecord;
    return (*(this));
}

auto DNSRequestResponse::operator=(IPCTypeRecord&& aRhs) -> DNSRequestResponse&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_IPCTypeRecord()) IPCTypeRecord(std::move(aRhs));
    mType = TIPCTypeRecord;
    return (*(this));
}

auto DNSRequestResponse::operator=(const nsresult& aRhs) -> DNSRequestResponse&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(aRhs);
    mType = Tnsresult;
    return (*(this));
}

auto DNSRequestResponse::operator=(nsresult&& aRhs) -> DNSRequestResponse&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(std::move(aRhs));
    mType = Tnsresult;
    return (*(this));
}

auto DNSRequestResponse::operator=(const DNSRequestResponse& aRhs) -> DNSRequestResponse&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TDNSRecord:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_DNSRecord()) DNSRecord((aRhs).get_DNSRecord());
            break;
        }
    case TIPCTypeRecord:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_IPCTypeRecord()) IPCTypeRecord((aRhs).get_IPCTypeRecord());
            break;
        }
    case Tnsresult:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_nsresult()) nsresult((aRhs).get_nsresult());
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    mType = t;
    return (*(this));
}

auto DNSRequestResponse::operator=(DNSRequestResponse&& aRhs) -> DNSRequestResponse&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TDNSRecord:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_DNSRecord()) DNSRecord(std::move((aRhs).get_DNSRecord()));
            (aRhs).MaybeDestroy();
            break;
        }
    case TIPCTypeRecord:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_IPCTypeRecord()) IPCTypeRecord(std::move((aRhs).get_IPCTypeRecord()));
            (aRhs).MaybeDestroy();
            break;
        }
    case Tnsresult:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(std::move((aRhs).get_nsresult()));
            (aRhs).MaybeDestroy();
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    (aRhs).mType = T__None;
    mType = t;
    return (*(this));
}

} // namespace net
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::net::DNSRequestResponse>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    typedef ::mozilla::net::DNSRequestResponse union__;
    int type = (aVar).type();
    IPC::WriteParam(aWriter, type);
    // Sentinel = 'DNSRequestResponse'
    (aWriter)->WriteSentinel(1077151518);

    switch (type) {
    case union__::TDNSRecord:
        {
            IPC::WriteParam(aWriter, (aVar).get_DNSRecord());
            // Sentinel = 'TDNSRecord'
            (aWriter)->WriteSentinel(309396377);
            return;
        }
    case union__::TIPCTypeRecord:
        {
            IPC::WriteParam(aWriter, (aVar).get_IPCTypeRecord());
            // Sentinel = 'TIPCTypeRecord'
            (aWriter)->WriteSentinel(617481522);
            return;
        }
    case union__::Tnsresult:
        {
            IPC::WriteParam(aWriter, (aVar).get_nsresult());
            // Sentinel = 'Tnsresult'
            (aWriter)->WriteSentinel(313394133);
            return;
        }
    default:
        {
            aWriter->FatalError("unknown variant of union DNSRequestResponse");
            return;
        }
    }
}

auto ParamTraits<::mozilla::net::DNSRequestResponse>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    typedef ::mozilla::net::DNSRequestResponse union__;
    auto maybe__type = IPC::ReadParam<int>(aReader);
    if (!maybe__type) {
        aReader->FatalError("Error deserializing type of union DNSRequestResponse");
        return {};

    }
    auto& type = *maybe__type;
    // Sentinel = 'DNSRequestResponse'
    if ((!((aReader)->ReadSentinel(1077151518)))) {
        mozilla::ipc::SentinelReadError("Error deserializing type of union DNSRequestResponse");
        return {};
    }

    switch (type) {
    case union__::TDNSRecord:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::net::DNSRecord>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TDNSRecord of union DNSRequestResponse");
                return {};

            }
            auto& tmp = *maybe__tmp;
            // Sentinel = 'TDNSRecord'
            if ((!((aReader)->ReadSentinel(309396377)))) {
                mozilla::ipc::SentinelReadError("Error deserializing variant TDNSRecord of union DNSRequestResponse");
                return {};
            }
            return std::move(tmp);
        }
    case union__::TIPCTypeRecord:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::net::IPCTypeRecord>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TIPCTypeRecord of union DNSRequestResponse");
                return {};

            }
            auto& tmp = *maybe__tmp;
            // Sentinel = 'TIPCTypeRecord'
            if ((!((aReader)->ReadSentinel(617481522)))) {
                mozilla::ipc::SentinelReadError("Error deserializing variant TIPCTypeRecord of union DNSRequestResponse");
                return {};
            }
            return std::move(tmp);
        }
    case union__::Tnsresult:
        {
            auto maybe__tmp = IPC::ReadParam<::nsresult>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant Tnsresult of union DNSRequestResponse");
                return {};

            }
            auto& tmp = *maybe__tmp;
            // Sentinel = 'Tnsresult'
            if ((!((aReader)->ReadSentinel(313394133)))) {
                mozilla::ipc::SentinelReadError("Error deserializing variant Tnsresult of union DNSRequestResponse");
                return {};
            }
            return std::move(tmp);
        }
    default:
        {
            aReader->FatalError("unknown variant of union DNSRequestResponse");
            return {};
        }
    }
}

} // namespace IPC
