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

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

// This file defines XDataView for type traits and can be included in
// _mojom_traits.h definitions but otherwise please use .mojom-forward.h,
// .mojom-shared.h or .mojom.h.

// IWYU pragma: private
// IWYU pragma: friend "traits"

#ifndef SERVICES_NETWORK_PUBLIC_MOJOM_CERT_VERIFY_RESULT_MOJOM_DATA_VIEW_H_
#define SERVICES_NETWORK_PUBLIC_MOJOM_CERT_VERIFY_RESULT_MOJOM_DATA_VIEW_H_

#include <stdint.h>

#include <functional>
#include <iosfwd>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/array_data_view.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"

#include "services/network/public/mojom/cert_verify_result.mojom-shared-internal.h"
#include "services/network/public/mojom/ct_policy_status.mojom-shared.h"
#include "services/network/public/mojom/hash_value.mojom-shared.h"
#include "services/network/public/mojom/ocsp_verify_result.mojom-shared.h"
#include "services/network/public/mojom/signed_certificate_timestamp_and_status.mojom-shared.h"
#include "services/network/public/mojom/x509_certificate.mojom-shared.h"


namespace network::mojom {
class CertVerifyResultDataView;



}  // network::mojom


namespace mojo {
namespace internal {

template <>
struct MojomTypeTraits<::network::mojom::CertVerifyResultDataView> {
  using Data = ::network::mojom::internal::CertVerifyResult_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

}  // namespace internal
}  // namespace mojo


namespace network::mojom {


class CertVerifyResultDataView {
 public:
  CertVerifyResultDataView() = default;

  CertVerifyResultDataView(
      internal::CertVerifyResult_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  inline void GetVerifiedCertDataView(
      ::network::mojom::X509CertificateDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadVerifiedCert(UserType* output) {
    
static_assert(
    mojo::internal::IsValidUserTypeForOptionalValue<
        ::network::mojom::X509CertificateDataView, UserType>(),
    "Attempting to read the optional `verified_cert` field into a type which "
    "cannot represent a null value. Either wrap the destination object "
    "with std::optional, ensure that any corresponding "
    "{Struct/Union/Array/String}Traits define the necessary IsNull and "
    "SetToNull methods, or use `MaybeReadVerifiedCert` instead "
    "of `ReadVerifiedCert if you're fine with null values being "
    "silently ignored in this case.");
    auto* pointer = data_->verified_cert.Get();
    return mojo::internal::Deserialize<::network::mojom::X509CertificateDataView>(
        pointer, output, message_);
  }
  uint32_t cert_status() const {
    return data_->cert_status;
  }
  inline void GetPublicKeyHashesDataView(
      mojo::ArrayDataView<::network::mojom::SHA256HashValueDataView>* output);

  template <typename UserType>
  [[nodiscard]] bool ReadPublicKeyHashes(UserType* output) {
    
    auto* pointer = data_->public_key_hashes.Get();
    return mojo::internal::Deserialize<mojo::ArrayDataView<::network::mojom::SHA256HashValueDataView>>(
        pointer, output, message_);
  }
  bool is_issued_by_known_root() const {
    return data_->is_issued_by_known_root;
  }
  inline void GetOcspResultDataView(
      ::network::mojom::OCSPVerifyResultDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadOcspResult(UserType* output) {
    
    auto* pointer = data_->ocsp_result.Get();
    return mojo::internal::Deserialize<::network::mojom::OCSPVerifyResultDataView>(
        pointer, output, message_);
  }
  inline void GetSctsDataView(
      mojo::ArrayDataView<::network::mojom::SignedCertificateTimestampAndStatusDataView>* output);

  template <typename UserType>
  [[nodiscard]] bool ReadScts(UserType* output) {
    
    auto* pointer = data_->scts.Get();
    return mojo::internal::Deserialize<mojo::ArrayDataView<::network::mojom::SignedCertificateTimestampAndStatusDataView>>(
        pointer, output, message_);
  }
  template <typename UserType>
  [[nodiscard]] bool ReadPolicyCompliance(UserType* output) const {
    auto data_value = data_->policy_compliance;
    return mojo::internal::Deserialize<::network::mojom::CTPolicyCompliance>(
        data_value, output);
  }
  ::network::mojom::CTPolicyCompliance policy_compliance() const {
    return ::mojo::internal::ToKnownEnumValueHelper(
          static_cast<::network::mojom::CTPolicyCompliance>(data_->policy_compliance));
  }
  template <typename UserType>
  [[nodiscard]] bool ReadCtRequirementStatus(UserType* output) const {
    auto data_value = data_->ct_requirement_status;
    return mojo::internal::Deserialize<::network::mojom::CTRequirementsStatus>(
        data_value, output);
  }
  ::network::mojom::CTRequirementsStatus ct_requirement_status() const {
    return ::mojo::internal::ToKnownEnumValueHelper(
          static_cast<::network::mojom::CTRequirementsStatus>(data_->ct_requirement_status));
  }
  std::optional<int32_t> crs_root_id() const {

    return data_->crs_root_id_$flag
        ? std::make_optional(data_->crs_root_id_$value)
        : std::nullopt;
  }
 private:
  internal::CertVerifyResult_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


}  // network::mojom

#endif  // SERVICES_NETWORK_PUBLIC_MOJOM_CERT_VERIFY_RESULT_MOJOM_DATA_VIEW_H_