// services/network/public/mojom/cert_verify_result.mojom.h is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_NETWORK_PUBLIC_MOJOM_CERT_VERIFY_RESULT_MOJOM_H_
#define SERVICES_NETWORK_PUBLIC_MOJOM_CERT_VERIFY_RESULT_MOJOM_H_

#include <stdint.h>

#include <limits>
#include <optional>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/clone_traits.h"
#include "mojo/public/cpp/bindings/equals_traits.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "mojo/public/cpp/bindings/union_traits.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"

#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"

#include "services/network/public/mojom/cert_verify_result.mojom-features.h"  // IWYU pragma: export
#include "services/network/public/mojom/cert_verify_result.mojom-shared.h"  // IWYU pragma: export
#include "services/network/public/mojom/cert_verify_result.mojom-forward.h"  // IWYU pragma: export
#include "services/network/public/mojom/ct_policy_status.mojom.h"
#include "services/network/public/mojom/hash_value.mojom.h"
#include "services/network/public/mojom/ocsp_verify_result.mojom.h"
#include "services/network/public/mojom/signed_certificate_timestamp_and_status.mojom.h"
#include "services/network/public/mojom/x509_certificate.mojom.h"
#include <string>
#include <vector>




#include "services/network/public/cpp/cert_verify_result_mojom_traits.h"




namespace network::mojom {








class  CertVerifyResult {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<CertVerifyResult, T>::value>;
  using DataView = CertVerifyResultDataView;
  using Data_ = internal::CertVerifyResult_Data;

  template <typename... Args>
  static CertVerifyResultPtr New(Args&&... args) {
    return CertVerifyResultPtr(
        std::in_place, std::forward<Args>(args)...);
  }

  template <typename U>
  static CertVerifyResultPtr From(const U& u) {
    return mojo::TypeConverter<CertVerifyResultPtr, U>::Convert(u);
  }

  template <typename U>
  U To() const {
    return mojo::TypeConverter<U, CertVerifyResult>::Convert(*this);
  }


  CertVerifyResult();

  CertVerifyResult(
      const ::scoped_refptr<::net::X509Certificate>& verified_cert,
      uint32_t cert_status,
      std::vector<::net::SHA256HashValue> public_key_hashes,
      bool is_issued_by_known_root,
      const ::bssl::OCSPVerifyResult& ocsp_result,
      std::vector<::net::SignedCertificateTimestampAndStatus> scts,
      ::net::ct::CTPolicyCompliance policy_compliance,
      ::net::ct::CTRequirementsStatus ct_requirement_status,
      std::optional<int32_t> crs_root_id);


  ~CertVerifyResult();

  // Clone() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Clone() or copy
  // constructor/assignment are available for members.
  template <typename StructPtrType = CertVerifyResultPtr>
  CertVerifyResultPtr Clone() const;

  // Equals() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Equals() or == operator
  // are available for members.
  template <typename T, CertVerifyResult::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

  template <typename T, CertVerifyResult::EnableIfSame<T>* = nullptr>
  bool operator==(const T& rhs) const { return Equals(rhs); }

  template <typename T, CertVerifyResult::EnableIfSame<T>* = nullptr>
  bool operator!=(const T& rhs) const { return !operator==(rhs); }

  template <mojo::internal::SendValidation send_validation, typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        CertVerifyResult::DataView, std::vector<uint8_t>, send_validation>(input);
  }

  template <typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        CertVerifyResult::DataView, std::vector<uint8_t>>(input);
  }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        CertVerifyResult::DataView>(input);
  }

  // The returned Message is serialized only if the message is moved
  // cross-process or cross-language. Otherwise if the message is Deserialized
  // as the same UserType |input| will just be moved to |output| in
  // DeserializeFromMessage.
  template <typename UserType>
  static mojo::Message WrapAsMessage(UserType input) {
    return mojo::Message(std::make_unique<
        internal::CertVerifyResult_UnserializedMessageContext<
            UserType, CertVerifyResult::DataView>>(0, 0, std::move(input)),
        MOJO_CREATE_MESSAGE_FLAG_NONE);
  }

  template <typename UserType>
  static bool Deserialize(const void* data,
                          size_t data_num_bytes,
                          UserType* output) {
    mojo::Message message;
    return mojo::internal::DeserializeImpl<CertVerifyResult::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return CertVerifyResult::Deserialize(
        input.empty() ? nullptr : input.data(), input.size(), output);
  }

  template <typename UserType>
  static bool DeserializeFromMessage(mojo::Message input,
                                     UserType* output) {
    auto context = input.TakeUnserializedContext<
        internal::CertVerifyResult_UnserializedMessageContext<
            UserType, CertVerifyResult::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<CertVerifyResult::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  ::scoped_refptr<::net::X509Certificate> verified_cert;
  
  uint32_t cert_status;
  
  std::vector<::net::SHA256HashValue> public_key_hashes;
  
  bool is_issued_by_known_root;
  
  ::bssl::OCSPVerifyResult ocsp_result;
  
  std::vector<::net::SignedCertificateTimestampAndStatus> scts;
  
  ::net::ct::CTPolicyCompliance policy_compliance;
  
  ::net::ct::CTRequirementsStatus ct_requirement_status;
  
  std::optional<int32_t> crs_root_id;

  // Serialise this struct into a trace.
  void WriteIntoTrace(perfetto::TracedValue traced_context) const;

 private:
  static bool Validate(const void* data,
                       mojo::internal::ValidationContext* validation_context);
};

// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, CertVerifyResult::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

template <typename T, CertVerifyResult::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
  return !(rhs < lhs);
}

template <typename T, CertVerifyResult::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
  return rhs < lhs;
}

template <typename T, CertVerifyResult::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
  return !(lhs < rhs);
}

template <typename StructPtrType>
CertVerifyResultPtr CertVerifyResult::Clone() const {
  return New(
      mojo::Clone(verified_cert),
      mojo::Clone(cert_status),
      mojo::Clone(public_key_hashes),
      mojo::Clone(is_issued_by_known_root),
      mojo::Clone(ocsp_result),
      mojo::Clone(scts),
      mojo::Clone(policy_compliance),
      mojo::Clone(ct_requirement_status),
      mojo::Clone(crs_root_id)
  );
}

template <typename T, CertVerifyResult::EnableIfSame<T>*>
bool CertVerifyResult::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->verified_cert, other_struct.verified_cert))
    return false;
  if (!mojo::Equals(this->cert_status, other_struct.cert_status))
    return false;
  if (!mojo::Equals(this->public_key_hashes, other_struct.public_key_hashes))
    return false;
  if (!mojo::Equals(this->is_issued_by_known_root, other_struct.is_issued_by_known_root))
    return false;
  if (!mojo::Equals(this->ocsp_result, other_struct.ocsp_result))
    return false;
  if (!mojo::Equals(this->scts, other_struct.scts))
    return false;
  if (!mojo::Equals(this->policy_compliance, other_struct.policy_compliance))
    return false;
  if (!mojo::Equals(this->ct_requirement_status, other_struct.ct_requirement_status))
    return false;
  if (!mojo::Equals(this->crs_root_id, other_struct.crs_root_id))
    return false;
  return true;
}

template <typename T, CertVerifyResult::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.verified_cert < rhs.verified_cert)
    return true;
  if (rhs.verified_cert < lhs.verified_cert)
    return false;
  if (lhs.cert_status < rhs.cert_status)
    return true;
  if (rhs.cert_status < lhs.cert_status)
    return false;
  if (lhs.public_key_hashes < rhs.public_key_hashes)
    return true;
  if (rhs.public_key_hashes < lhs.public_key_hashes)
    return false;
  if (lhs.is_issued_by_known_root < rhs.is_issued_by_known_root)
    return true;
  if (rhs.is_issued_by_known_root < lhs.is_issued_by_known_root)
    return false;
  if (lhs.ocsp_result < rhs.ocsp_result)
    return true;
  if (rhs.ocsp_result < lhs.ocsp_result)
    return false;
  if (lhs.scts < rhs.scts)
    return true;
  if (rhs.scts < lhs.scts)
    return false;
  if (lhs.policy_compliance < rhs.policy_compliance)
    return true;
  if (rhs.policy_compliance < lhs.policy_compliance)
    return false;
  if (lhs.ct_requirement_status < rhs.ct_requirement_status)
    return true;
  if (rhs.ct_requirement_status < lhs.ct_requirement_status)
    return false;
  if (lhs.crs_root_id < rhs.crs_root_id)
    return true;
  if (rhs.crs_root_id < lhs.crs_root_id)
    return false;
  return false;
}


}  // network::mojom

namespace mojo {


template <>
struct  StructTraits<::network::mojom::CertVerifyResult::DataView,
                                         ::network::mojom::CertVerifyResultPtr> {
  static bool IsNull(const ::network::mojom::CertVerifyResultPtr& input) { return !input; }
  static void SetToNull(::network::mojom::CertVerifyResultPtr* output) { output->reset(); }

  static const decltype(::network::mojom::CertVerifyResult::verified_cert)& verified_cert(
      const ::network::mojom::CertVerifyResultPtr& input) {
    return input->verified_cert;
  }

  static decltype(::network::mojom::CertVerifyResult::cert_status) cert_status(
      const ::network::mojom::CertVerifyResultPtr& input) {
    return input->cert_status;
  }

  static const decltype(::network::mojom::CertVerifyResult::public_key_hashes)& public_key_hashes(
      const ::network::mojom::CertVerifyResultPtr& input) {
    return input->public_key_hashes;
  }

  static decltype(::network::mojom::CertVerifyResult::is_issued_by_known_root) is_issued_by_known_root(
      const ::network::mojom::CertVerifyResultPtr& input) {
    return input->is_issued_by_known_root;
  }

  static const decltype(::network::mojom::CertVerifyResult::ocsp_result)& ocsp_result(
      const ::network::mojom::CertVerifyResultPtr& input) {
    return input->ocsp_result;
  }

  static const decltype(::network::mojom::CertVerifyResult::scts)& scts(
      const ::network::mojom::CertVerifyResultPtr& input) {
    return input->scts;
  }

  static decltype(::network::mojom::CertVerifyResult::policy_compliance) policy_compliance(
      const ::network::mojom::CertVerifyResultPtr& input) {
    return input->policy_compliance;
  }

  static decltype(::network::mojom::CertVerifyResult::ct_requirement_status) ct_requirement_status(
      const ::network::mojom::CertVerifyResultPtr& input) {
    return input->ct_requirement_status;
  }

  static decltype(::network::mojom::CertVerifyResult::crs_root_id) crs_root_id(
      const ::network::mojom::CertVerifyResultPtr& input) {
    return input->crs_root_id;
  }

  static bool Read(::network::mojom::CertVerifyResult::DataView input, ::network::mojom::CertVerifyResultPtr* output);
};

}  // namespace mojo

#endif  // SERVICES_NETWORK_PUBLIC_MOJOM_CERT_VERIFY_RESULT_MOJOM_H_