// services/network/public/mojom/ssl_info.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_SSL_INFO_MOJOM_DATA_VIEW_H_
#define SERVICES_NETWORK_PUBLIC_MOJOM_SSL_INFO_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/ssl_info.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/signed_certificate_timestamp_and_status.mojom-shared.h"
#include "services/network/public/mojom/x509_certificate.mojom-shared.h"


namespace network::mojom {
class SSLInfoDataView;



}  // network::mojom


namespace mojo {
namespace internal {

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

}  // namespace internal
}  // namespace mojo


namespace network::mojom {


enum class SSLInfoHandshakeType : int32_t {
  
  kUnknown = 0,
  
  kResume = 1,
  
  kFull = 2,
  kMinValue = 0,
  kMaxValue = 2,
};

 std::ostream& operator<<(std::ostream& os, SSLInfoHandshakeType value);
inline bool IsKnownEnumValue(SSLInfoHandshakeType value) {
  return internal::SSLInfoHandshakeType_Data::IsKnownValue(
      static_cast<int32_t>(value));
}

// Returns true if the enum has an infallible conversion from the mojom enum.
consteval bool HasInfallibleConversion(SSLInfoHandshakeType) {
  return true;
}


class SSLInfoDataView {
 public:
  SSLInfoDataView() = default;

  SSLInfoDataView(
      internal::SSLInfo_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

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

  template <typename UserType>
  [[nodiscard]] bool ReadCert(UserType* output) {
    
static_assert(
    mojo::internal::IsValidUserTypeForOptionalValue<
        ::network::mojom::X509CertificateDataView, UserType>(),
    "Attempting to read the optional `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 `MaybeReadCert` instead "
    "of `ReadCert if you're fine with null values being "
    "silently ignored in this case.");
    auto* pointer = data_->cert.Get();
    return mojo::internal::Deserialize<::network::mojom::X509CertificateDataView>(
        pointer, output, message_);
  }
  inline void GetUnverifiedCertDataView(
      ::network::mojom::X509CertificateDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadUnverifiedCert(UserType* output) {
    
static_assert(
    mojo::internal::IsValidUserTypeForOptionalValue<
        ::network::mojom::X509CertificateDataView, UserType>(),
    "Attempting to read the optional `unverified_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 `MaybeReadUnverifiedCert` instead "
    "of `ReadUnverifiedCert if you're fine with null values being "
    "silently ignored in this case.");
    auto* pointer = data_->unverified_cert.Get();
    return mojo::internal::Deserialize<::network::mojom::X509CertificateDataView>(
        pointer, output, message_);
  }
  uint32_t cert_status() const {
    return data_->cert_status;
  }
  uint16_t key_exchange_group() const {
    return data_->key_exchange_group;
  }
  uint16_t peer_signature_algorithm() const {
    return data_->peer_signature_algorithm;
  }
  int32_t connection_status() const {
    return data_->connection_status;
  }
  bool is_issued_by_known_root() const {
    return data_->is_issued_by_known_root;
  }
  bool pkp_bypassed() const {
    return data_->pkp_bypassed;
  }
  bool client_cert_sent() const {
    return data_->client_cert_sent;
  }
  bool encrypted_client_hello() const {
    return data_->encrypted_client_hello;
  }
  template <typename UserType>
  [[nodiscard]] bool ReadHandshakeType(UserType* output) const {
    auto data_value = data_->handshake_type;
    return mojo::internal::Deserialize<::network::mojom::SSLInfoHandshakeType>(
        data_value, output);
  }
  SSLInfoHandshakeType handshake_type() const {
    return ::mojo::internal::ToKnownEnumValueHelper(
          static_cast<::network::mojom::SSLInfoHandshakeType>(data_->handshake_type));
  }
  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_);
  }
  inline void GetSignedCertificateTimestampsDataView(
      mojo::ArrayDataView<::network::mojom::SignedCertificateTimestampAndStatusDataView>* output);

  template <typename UserType>
  [[nodiscard]] bool ReadSignedCertificateTimestamps(UserType* output) {
    
    auto* pointer = data_->signed_certificate_timestamps.Get();
    return mojo::internal::Deserialize<mojo::ArrayDataView<::network::mojom::SignedCertificateTimestampAndStatusDataView>>(
        pointer, output, message_);
  }
  template <typename UserType>
  [[nodiscard]] bool ReadCtPolicyCompliance(UserType* output) const {
    auto data_value = data_->ct_policy_compliance;
    return mojo::internal::Deserialize<::network::mojom::CTPolicyCompliance>(
        data_value, output);
  }
  ::network::mojom::CTPolicyCompliance ct_policy_compliance() const {
    return ::mojo::internal::ToKnownEnumValueHelper(
          static_cast<::network::mojom::CTPolicyCompliance>(data_->ct_policy_compliance));
  }
  bool is_fatal_cert_error() const {
    return data_->is_fatal_cert_error;
  }
 private:
  internal::SSLInfo_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


}  // network::mojom

#endif  // SERVICES_NETWORK_PUBLIC_MOJOM_SSL_INFO_MOJOM_DATA_VIEW_H_