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


#include "mozilla/psm/PSMIPCTypes.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 ByteArray|
//
namespace mozilla {
namespace psm {
} // namespace psm
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::psm::ByteArray>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).data());
    // Sentinel = 'data'
    (aWriter)->WriteSentinel(67109275);
}

auto ParamTraits<::mozilla::psm::ByteArray>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe___data = IPC::ReadParam<nsTArray<::uint8_t>>(aReader);
    if (!maybe___data) {
        aReader->FatalError("Error deserializing 'data' (uint8_t[]) member of 'ByteArray'");
        return {};

    }
    auto& _data = *maybe___data;
    // Sentinel = 'data'
    if ((!((aReader)->ReadSentinel(67109275)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'data' (uint8_t[]) member of 'ByteArray'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_data)};
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |struct ECKey|
//
namespace mozilla {
namespace psm {
} // namespace psm
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::psm::ECKey>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).params());
    // Sentinel = 'params'
    (aWriter)->WriteSentinel(146997893);
    IPC::WriteParam(aWriter, (aVar).cert());
    // Sentinel = 'cert'
    (aWriter)->WriteSentinel(68616623);
}

auto ParamTraits<::mozilla::psm::ECKey>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe___params = IPC::ReadParam<nsTArray<::uint8_t>>(aReader);
    if (!maybe___params) {
        aReader->FatalError("Error deserializing 'params' (uint8_t[]) member of 'ECKey'");
        return {};

    }
    auto& _params = *maybe___params;
    // Sentinel = 'params'
    if ((!((aReader)->ReadSentinel(146997893)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'params' (uint8_t[]) member of 'ECKey'");
        return {};
    }
    auto maybe___cert = IPC::ReadParam<nsTArray<::uint8_t>>(aReader);
    if (!maybe___cert) {
        aReader->FatalError("Error deserializing 'cert' (uint8_t[]) member of 'ECKey'");
        return {};

    }
    auto& _cert = *maybe___cert;
    // Sentinel = 'cert'
    if ((!((aReader)->ReadSentinel(68616623)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'cert' (uint8_t[]) member of 'ECKey'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_params),
            std::move(_cert)};
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |struct RSAKey|
//
namespace mozilla {
namespace psm {
} // namespace psm
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::psm::RSAKey>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).modulus());
    // Sentinel = 'modulus'
    (aWriter)->WriteSentinel(201655050);
    IPC::WriteParam(aWriter, (aVar).cert());
    // Sentinel = 'cert'
    (aWriter)->WriteSentinel(68616623);
}

auto ParamTraits<::mozilla::psm::RSAKey>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe___modulus = IPC::ReadParam<nsTArray<::uint8_t>>(aReader);
    if (!maybe___modulus) {
        aReader->FatalError("Error deserializing 'modulus' (uint8_t[]) member of 'RSAKey'");
        return {};

    }
    auto& _modulus = *maybe___modulus;
    // Sentinel = 'modulus'
    if ((!((aReader)->ReadSentinel(201655050)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'modulus' (uint8_t[]) member of 'RSAKey'");
        return {};
    }
    auto maybe___cert = IPC::ReadParam<nsTArray<::uint8_t>>(aReader);
    if (!maybe___cert) {
        aReader->FatalError("Error deserializing 'cert' (uint8_t[]) member of 'RSAKey'");
        return {};

    }
    auto& _cert = *maybe___cert;
    // Sentinel = 'cert'
    if ((!((aReader)->ReadSentinel(68616623)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'cert' (uint8_t[]) member of 'RSAKey'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_modulus),
            std::move(_cert)};
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |struct Certificate|
//
namespace mozilla {
namespace psm {
} // namespace psm
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::psm::Certificate>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).der());
    // Sentinel = 'der'
    (aWriter)->WriteSentinel(40567100);
}

auto ParamTraits<::mozilla::psm::Certificate>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe___der = IPC::ReadParam<nsTArray<::uint8_t>>(aReader);
    if (!maybe___der) {
        aReader->FatalError("Error deserializing 'der' (uint8_t[]) member of 'Certificate'");
        return {};

    }
    auto& _der = *maybe___der;
    // Sentinel = 'der'
    if ((!((aReader)->ReadSentinel(40567100)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'der' (uint8_t[]) member of 'Certificate'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_der)};
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |union IPCClientCertObject|
//
namespace mozilla {
namespace psm {
auto IPCClientCertObject::MaybeDestroy() -> void
{
    if ((mType) == (T__None)) {
        return;
    }
    switch (mType) {
    case TECKey:
        {
            (ptr_ECKey())->~ECKey__tdef();
            break;
        }
    case TRSAKey:
        {
            (ptr_RSAKey())->~RSAKey__tdef();
            break;
        }
    case TCertificate:
        {
            (ptr_Certificate())->~Certificate__tdef();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("not reached");
            break;
        }
    }
}

MOZ_IMPLICIT IPCClientCertObject::IPCClientCertObject(const ECKey& aOther)
{
    new (mozilla::KnownNotNull, ptr_ECKey()) ECKey(aOther);
    mType = TECKey;
}

MOZ_IMPLICIT IPCClientCertObject::IPCClientCertObject(ECKey&& aOther)
{
    new (mozilla::KnownNotNull, ptr_ECKey()) ECKey(std::move(aOther));
    mType = TECKey;
}

MOZ_IMPLICIT IPCClientCertObject::IPCClientCertObject(const RSAKey& aOther)
{
    new (mozilla::KnownNotNull, ptr_RSAKey()) RSAKey(aOther);
    mType = TRSAKey;
}

MOZ_IMPLICIT IPCClientCertObject::IPCClientCertObject(RSAKey&& aOther)
{
    new (mozilla::KnownNotNull, ptr_RSAKey()) RSAKey(std::move(aOther));
    mType = TRSAKey;
}

MOZ_IMPLICIT IPCClientCertObject::IPCClientCertObject(const Certificate& aOther)
{
    new (mozilla::KnownNotNull, ptr_Certificate()) Certificate(aOther);
    mType = TCertificate;
}

MOZ_IMPLICIT IPCClientCertObject::IPCClientCertObject(Certificate&& aOther)
{
    new (mozilla::KnownNotNull, ptr_Certificate()) Certificate(std::move(aOther));
    mType = TCertificate;
}

MOZ_IMPLICIT IPCClientCertObject::IPCClientCertObject(const IPCClientCertObject& aOther)
{
    (aOther).AssertSanity();
    switch ((aOther).type()) {
    case TECKey:
        {
            new (mozilla::KnownNotNull, ptr_ECKey()) ECKey((aOther).get_ECKey());
            break;
        }
    case TRSAKey:
        {
            new (mozilla::KnownNotNull, ptr_RSAKey()) RSAKey((aOther).get_RSAKey());
            break;
        }
    case TCertificate:
        {
            new (mozilla::KnownNotNull, ptr_Certificate()) Certificate((aOther).get_Certificate());
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    mType = (aOther).type();
}

MOZ_IMPLICIT IPCClientCertObject::IPCClientCertObject(IPCClientCertObject&& aOther)
{
    (aOther).AssertSanity();
    Type t = (aOther).type();
    switch (t) {
    case TECKey:
        {
            new (mozilla::KnownNotNull, ptr_ECKey()) ECKey(std::move((aOther).get_ECKey()));
            (aOther).MaybeDestroy();
            break;
        }
    case TRSAKey:
        {
            new (mozilla::KnownNotNull, ptr_RSAKey()) RSAKey(std::move((aOther).get_RSAKey()));
            (aOther).MaybeDestroy();
            break;
        }
    case TCertificate:
        {
            new (mozilla::KnownNotNull, ptr_Certificate()) Certificate(std::move((aOther).get_Certificate()));
            (aOther).MaybeDestroy();
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    (aOther).mType = T__None;
    mType = t;
}

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

auto IPCClientCertObject::operator=(const ECKey& aRhs) -> IPCClientCertObject&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_ECKey()) ECKey(aRhs);
    mType = TECKey;
    return (*(this));
}

auto IPCClientCertObject::operator=(ECKey&& aRhs) -> IPCClientCertObject&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_ECKey()) ECKey(std::move(aRhs));
    mType = TECKey;
    return (*(this));
}

auto IPCClientCertObject::operator=(const RSAKey& aRhs) -> IPCClientCertObject&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_RSAKey()) RSAKey(aRhs);
    mType = TRSAKey;
    return (*(this));
}

auto IPCClientCertObject::operator=(RSAKey&& aRhs) -> IPCClientCertObject&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_RSAKey()) RSAKey(std::move(aRhs));
    mType = TRSAKey;
    return (*(this));
}

auto IPCClientCertObject::operator=(const Certificate& aRhs) -> IPCClientCertObject&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_Certificate()) Certificate(aRhs);
    mType = TCertificate;
    return (*(this));
}

auto IPCClientCertObject::operator=(Certificate&& aRhs) -> IPCClientCertObject&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_Certificate()) Certificate(std::move(aRhs));
    mType = TCertificate;
    return (*(this));
}

auto IPCClientCertObject::operator=(const IPCClientCertObject& aRhs) -> IPCClientCertObject&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TECKey:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_ECKey()) ECKey((aRhs).get_ECKey());
            break;
        }
    case TRSAKey:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_RSAKey()) RSAKey((aRhs).get_RSAKey());
            break;
        }
    case TCertificate:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_Certificate()) Certificate((aRhs).get_Certificate());
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    mType = t;
    return (*(this));
}

auto IPCClientCertObject::operator=(IPCClientCertObject&& aRhs) -> IPCClientCertObject&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TECKey:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_ECKey()) ECKey(std::move((aRhs).get_ECKey()));
            (aRhs).MaybeDestroy();
            break;
        }
    case TRSAKey:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_RSAKey()) RSAKey(std::move((aRhs).get_RSAKey()));
            (aRhs).MaybeDestroy();
            break;
        }
    case TCertificate:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_Certificate()) Certificate(std::move((aRhs).get_Certificate()));
            (aRhs).MaybeDestroy();
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    (aRhs).mType = T__None;
    mType = t;
    return (*(this));
}

} // namespace psm
} // namespace mozilla

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

    switch (type) {
    case union__::TECKey:
        {
            IPC::WriteParam(aWriter, (aVar).get_ECKey());
            // Sentinel = 'TECKey'
            (aWriter)->WriteSentinel(109511174);
            return;
        }
    case union__::TRSAKey:
        {
            IPC::WriteParam(aWriter, (aVar).get_RSAKey());
            // Sentinel = 'TRSAKey'
            (aWriter)->WriteSentinel(151388772);
            return;
        }
    case union__::TCertificate:
        {
            IPC::WriteParam(aWriter, (aVar).get_Certificate());
            // Sentinel = 'TCertificate'
            (aWriter)->WriteSentinel(498926776);
            return;
        }
    default:
        {
            aWriter->FatalError("unknown variant of union IPCClientCertObject");
            return;
        }
    }
}

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

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

    switch (type) {
    case union__::TECKey:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::psm::ECKey>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TECKey of union IPCClientCertObject");
                return {};

            }
            auto& tmp = *maybe__tmp;
            // Sentinel = 'TECKey'
            if ((!((aReader)->ReadSentinel(109511174)))) {
                mozilla::ipc::SentinelReadError("Error deserializing variant TECKey of union IPCClientCertObject");
                return {};
            }
            return std::move(tmp);
        }
    case union__::TRSAKey:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::psm::RSAKey>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TRSAKey of union IPCClientCertObject");
                return {};

            }
            auto& tmp = *maybe__tmp;
            // Sentinel = 'TRSAKey'
            if ((!((aReader)->ReadSentinel(151388772)))) {
                mozilla::ipc::SentinelReadError("Error deserializing variant TRSAKey of union IPCClientCertObject");
                return {};
            }
            return std::move(tmp);
        }
    case union__::TCertificate:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::psm::Certificate>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TCertificate of union IPCClientCertObject");
                return {};

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

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |struct DelegatedCredentialInfoArg|
//
namespace mozilla {
namespace psm {
auto DelegatedCredentialInfoArg::StaticAssertions() const -> void
{
    static_assert(
        (offsetof(DelegatedCredentialInfoArg, authKeyBits_) - offsetof(DelegatedCredentialInfoArg, scheme_)) == 4,
        "Bad assumptions about field layout!");
}

} // namespace psm
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::psm::DelegatedCredentialInfoArg>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    (aWriter)->WriteBytes((&((aVar).scheme())), 8);
    // Sentinel = 'scheme | authKeyBits'
    (aWriter)->WriteSentinel(1328285599);
}

auto ParamTraits<::mozilla::psm::DelegatedCredentialInfoArg>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    IPC::ReadResult<paramType> result__{
            std::in_place,
            ::uint32_t{0},
            ::uint32_t{0}};
    if ((!((aReader)->ReadBytesInto((&((result__)->scheme())), 8)))) {
        aReader->FatalError("Error bulk reading fields from uint32_t");
        return {};
    }
    // Sentinel = 'scheme | authKeyBits'
    if ((!((aReader)->ReadSentinel(1328285599)))) {
        mozilla::ipc::SentinelReadError("Error bulk reading fields from uint32_t");
        return {};
    }
    return result__;
}

} // namespace IPC
