// third_party/blink/public/mojom/remote_objects/remote_objects.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 THIRD_PARTY_BLINK_PUBLIC_MOJOM_REMOTE_OBJECTS_REMOTE_OBJECTS_MOJOM_DATA_VIEW_H_
#define THIRD_PARTY_BLINK_PUBLIC_MOJOM_REMOTE_OBJECTS_REMOTE_OBJECTS_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 "third_party/blink/public/mojom/remote_objects/remote_objects.mojom-shared-internal.h"
#include "mojo/public/mojom/base/big_buffer.mojom-shared.h"
#include "mojo/public/mojom/base/string16.mojom-shared.h"


namespace blink::mojom {
class RemoteTypedArrayDataView;

class RemoteInvocationResultDataView;

class RemoteInvocationArgumentDataView;
class RemoteInvocationResultValueDataView;


}  // blink::mojom


namespace mojo {
namespace internal {

template <>
struct MojomTypeTraits<::blink::mojom::RemoteTypedArrayDataView> {
  using Data = ::blink::mojom::internal::RemoteTypedArray_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

template <>
struct MojomTypeTraits<::blink::mojom::RemoteInvocationResultDataView> {
  using Data = ::blink::mojom::internal::RemoteInvocationResult_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

template <>
struct MojomTypeTraits<::blink::mojom::RemoteInvocationArgumentDataView> {
  using Data = ::blink::mojom::internal::RemoteInvocationArgument_Data;
  using DataAsArrayElement = Data;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kUnion;
};

template <>
struct MojomTypeTraits<::blink::mojom::RemoteInvocationResultValueDataView> {
  using Data = ::blink::mojom::internal::RemoteInvocationResultValue_Data;
  using DataAsArrayElement = Data;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kUnion;
};

}  // namespace internal
}  // namespace mojo


namespace blink::mojom {


enum class SingletonJavaScriptValue : int32_t {
  
  kNull = 0,
  
  kUndefined = 1,
  kMinValue = 0,
  kMaxValue = 1,
};

COMPONENT_EXPORT(MOJOM_SHARED_BLINK_COMMON_EXPORT) std::ostream& operator<<(std::ostream& os, SingletonJavaScriptValue value);
inline bool IsKnownEnumValue(SingletonJavaScriptValue value) {
  return internal::SingletonJavaScriptValue_Data::IsKnownValue(
      static_cast<int32_t>(value));
}

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


enum class RemoteArrayType : int32_t {
  
  kInt8Array = 1,
  
  kUint8Array = 2,
  
  kInt16Array = 3,
  
  kUint16Array = 4,
  
  kInt32Array = 5,
  
  kUint32Array = 6,
  
  kFloat32Array = 7,
  
  kFloat64Array = 8,
  kMinValue = 1,
  kMaxValue = 8,
};

COMPONENT_EXPORT(MOJOM_SHARED_BLINK_COMMON_EXPORT) std::ostream& operator<<(std::ostream& os, RemoteArrayType value);
inline bool IsKnownEnumValue(RemoteArrayType value) {
  return internal::RemoteArrayType_Data::IsKnownValue(
      static_cast<int32_t>(value));
}

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


enum class RemoteInvocationError : int32_t {
  
  OK = 0,
  
  METHOD_NOT_FOUND = 1,
  
  OBJECT_GET_CLASS_BLOCKED = 2,
  
  EXCEPTION_THROWN = 3,
  
  NON_ASSIGNABLE_TYPES = 4,
  kMinValue = 0,
  kMaxValue = 4,
};

COMPONENT_EXPORT(MOJOM_SHARED_BLINK_COMMON_EXPORT) std::ostream& operator<<(std::ostream& os, RemoteInvocationError value);
inline bool IsKnownEnumValue(RemoteInvocationError value) {
  return internal::RemoteInvocationError_Data::IsKnownValue(
      static_cast<int32_t>(value));
}

// Returns true if the enum has an infallible conversion from the mojom enum.
consteval bool HasInfallibleConversion(RemoteInvocationError) {
  return true;
}
// Interface base classes. They are used for type safety check.
class RemoteObjectHostInterfaceBase {};

using RemoteObjectHostPtrDataView =
    mojo::InterfacePtrDataView<RemoteObjectHostInterfaceBase>;
using RemoteObjectHostRequestDataView =
    mojo::InterfaceRequestDataView<RemoteObjectHostInterfaceBase>;
using RemoteObjectHostAssociatedPtrInfoDataView =
    mojo::AssociatedInterfacePtrInfoDataView<RemoteObjectHostInterfaceBase>;
using RemoteObjectHostAssociatedRequestDataView =
    mojo::AssociatedInterfaceRequestDataView<RemoteObjectHostInterfaceBase>;
class RemoteObjectInterfaceBase {};

using RemoteObjectPtrDataView =
    mojo::InterfacePtrDataView<RemoteObjectInterfaceBase>;
using RemoteObjectRequestDataView =
    mojo::InterfaceRequestDataView<RemoteObjectInterfaceBase>;
using RemoteObjectAssociatedPtrInfoDataView =
    mojo::AssociatedInterfacePtrInfoDataView<RemoteObjectInterfaceBase>;
using RemoteObjectAssociatedRequestDataView =
    mojo::AssociatedInterfaceRequestDataView<RemoteObjectInterfaceBase>;
class RemoteObjectGatewayFactoryInterfaceBase {};

using RemoteObjectGatewayFactoryPtrDataView =
    mojo::InterfacePtrDataView<RemoteObjectGatewayFactoryInterfaceBase>;
using RemoteObjectGatewayFactoryRequestDataView =
    mojo::InterfaceRequestDataView<RemoteObjectGatewayFactoryInterfaceBase>;
using RemoteObjectGatewayFactoryAssociatedPtrInfoDataView =
    mojo::AssociatedInterfacePtrInfoDataView<RemoteObjectGatewayFactoryInterfaceBase>;
using RemoteObjectGatewayFactoryAssociatedRequestDataView =
    mojo::AssociatedInterfaceRequestDataView<RemoteObjectGatewayFactoryInterfaceBase>;
class RemoteObjectGatewayInterfaceBase {};

using RemoteObjectGatewayPtrDataView =
    mojo::InterfacePtrDataView<RemoteObjectGatewayInterfaceBase>;
using RemoteObjectGatewayRequestDataView =
    mojo::InterfaceRequestDataView<RemoteObjectGatewayInterfaceBase>;
using RemoteObjectGatewayAssociatedPtrInfoDataView =
    mojo::AssociatedInterfacePtrInfoDataView<RemoteObjectGatewayInterfaceBase>;
using RemoteObjectGatewayAssociatedRequestDataView =
    mojo::AssociatedInterfaceRequestDataView<RemoteObjectGatewayInterfaceBase>;


class RemoteTypedArrayDataView {
 public:
  RemoteTypedArrayDataView() = default;

  RemoteTypedArrayDataView(
      internal::RemoteTypedArray_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  template <typename UserType>
  [[nodiscard]] bool ReadType(UserType* output) const {
    auto data_value = data_->type;
    return mojo::internal::Deserialize<::blink::mojom::RemoteArrayType>(
        data_value, output);
  }
  RemoteArrayType type() const {
    return ::mojo::internal::ToKnownEnumValueHelper(
          static_cast<::blink::mojom::RemoteArrayType>(data_->type));
  }
  inline void GetBufferDataView(
      ::mojo_base::mojom::BigBufferDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadBuffer(UserType* output) {
    
    auto* pointer = !data_->buffer.is_null() ? &data_->buffer : nullptr;
    return mojo::internal::Deserialize<::mojo_base::mojom::BigBufferDataView>(
        pointer, output, message_);
  }
 private:
  internal::RemoteTypedArray_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


class RemoteInvocationResultDataView {
 public:
  RemoteInvocationResultDataView() = default;

  RemoteInvocationResultDataView(
      internal::RemoteInvocationResult_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  template <typename UserType>
  [[nodiscard]] bool ReadError(UserType* output) const {
    auto data_value = data_->error;
    return mojo::internal::Deserialize<::blink::mojom::RemoteInvocationError>(
        data_value, output);
  }
  RemoteInvocationError error() const {
    return ::mojo::internal::ToKnownEnumValueHelper(
          static_cast<::blink::mojom::RemoteInvocationError>(data_->error));
  }
  inline void GetValueDataView(
      RemoteInvocationResultValueDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadValue(UserType* output) {
    
static_assert(
    mojo::internal::IsValidUserTypeForOptionalValue<
        ::blink::mojom::RemoteInvocationResultValueDataView, UserType>(),
    "Attempting to read the optional `value` 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 `MaybeReadValue` instead "
    "of `ReadValue if you're fine with null values being "
    "silently ignored in this case.");
    auto* pointer = !data_->value.is_null() ? &data_->value : nullptr;
    return mojo::internal::Deserialize<::blink::mojom::RemoteInvocationResultValueDataView>(
        pointer, output, message_);
  }
 private:
  internal::RemoteInvocationResult_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


class RemoteInvocationArgumentDataView {
 public:
  using Tag = internal::RemoteInvocationArgument_Data::RemoteInvocationArgument_Tag;

  RemoteInvocationArgumentDataView() = default;

  RemoteInvocationArgumentDataView(
      internal::RemoteInvocationArgument_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const {
    // For inlined unions, |data_| is always non-null. In that case we need to
    // check |data_->is_null()|.
    return !data_ || data_->is_null();
  }

  Tag tag() const { return data_->tag; }
  bool is_number_value() const { return data_->tag == Tag::kNumberValue; }
  double number_value() const {
    CHECK(is_number_value());
    return data_->data.f_number_value;
  }
  bool is_boolean_value() const { return data_->tag == Tag::kBooleanValue; }
  bool boolean_value() const {
    CHECK(is_boolean_value());
    return data_->data.f_boolean_value;
  }
  bool is_string_value() const { return data_->tag == Tag::kStringValue; }
  inline void GetStringValueDataView(
      ::mojo_base::mojom::String16DataView* output) const;

  template <typename UserType>
  [[nodiscard]] bool ReadStringValue(UserType* output) const {
    
    CHECK(is_string_value());
    return mojo::internal::Deserialize<::mojo_base::mojom::String16DataView>(
        data_->data.f_string_value.Get(), output, message_);
  }
  bool is_singleton_value() const { return data_->tag == Tag::kSingletonValue; }
  template <typename UserType>
  [[nodiscard]] bool ReadSingletonValue(UserType* output) const {
    CHECK(is_singleton_value());
    return mojo::internal::Deserialize<::blink::mojom::SingletonJavaScriptValue>(
        data_->data.f_singleton_value, output);
  }
  SingletonJavaScriptValue singleton_value() const {
    CHECK(is_singleton_value());
    // TODO(dcheng): This seems incorrect, as it bypasses enum traits.
    return ::mojo::internal::ToKnownEnumValueHelper(
        static_cast<::blink::mojom::SingletonJavaScriptValue>(data_->data.f_singleton_value));
  }
  bool is_array_value() const { return data_->tag == Tag::kArrayValue; }
  inline void GetArrayValueDataView(
      mojo::ArrayDataView<RemoteInvocationArgumentDataView>* output) const;

  template <typename UserType>
  [[nodiscard]] bool ReadArrayValue(UserType* output) const {
    
    CHECK(is_array_value());
    return mojo::internal::Deserialize<mojo::ArrayDataView<::blink::mojom::RemoteInvocationArgumentDataView>>(
        data_->data.f_array_value.Get(), output, message_);
  }
  bool is_typed_array_value() const { return data_->tag == Tag::kTypedArrayValue; }
  inline void GetTypedArrayValueDataView(
      RemoteTypedArrayDataView* output) const;

  template <typename UserType>
  [[nodiscard]] bool ReadTypedArrayValue(UserType* output) const {
    
    CHECK(is_typed_array_value());
    return mojo::internal::Deserialize<::blink::mojom::RemoteTypedArrayDataView>(
        data_->data.f_typed_array_value.Get(), output, message_);
  }
  bool is_object_id_value() const { return data_->tag == Tag::kObjectIdValue; }
  int32_t object_id_value() const {
    CHECK(is_object_id_value());
    return data_->data.f_object_id_value;
  }

 private:
  internal::RemoteInvocationArgument_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};



class RemoteInvocationResultValueDataView {
 public:
  using Tag = internal::RemoteInvocationResultValue_Data::RemoteInvocationResultValue_Tag;

  RemoteInvocationResultValueDataView() = default;

  RemoteInvocationResultValueDataView(
      internal::RemoteInvocationResultValue_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const {
    // For inlined unions, |data_| is always non-null. In that case we need to
    // check |data_->is_null()|.
    return !data_ || data_->is_null();
  }

  Tag tag() const { return data_->tag; }
  bool is_number_value() const { return data_->tag == Tag::kNumberValue; }
  double number_value() const {
    CHECK(is_number_value());
    return data_->data.f_number_value;
  }
  bool is_boolean_value() const { return data_->tag == Tag::kBooleanValue; }
  bool boolean_value() const {
    CHECK(is_boolean_value());
    return data_->data.f_boolean_value;
  }
  bool is_string_value() const { return data_->tag == Tag::kStringValue; }
  inline void GetStringValueDataView(
      ::mojo_base::mojom::String16DataView* output) const;

  template <typename UserType>
  [[nodiscard]] bool ReadStringValue(UserType* output) const {
    
    CHECK(is_string_value());
    return mojo::internal::Deserialize<::mojo_base::mojom::String16DataView>(
        data_->data.f_string_value.Get(), output, message_);
  }
  bool is_singleton_value() const { return data_->tag == Tag::kSingletonValue; }
  template <typename UserType>
  [[nodiscard]] bool ReadSingletonValue(UserType* output) const {
    CHECK(is_singleton_value());
    return mojo::internal::Deserialize<::blink::mojom::SingletonJavaScriptValue>(
        data_->data.f_singleton_value, output);
  }
  SingletonJavaScriptValue singleton_value() const {
    CHECK(is_singleton_value());
    // TODO(dcheng): This seems incorrect, as it bypasses enum traits.
    return ::mojo::internal::ToKnownEnumValueHelper(
        static_cast<::blink::mojom::SingletonJavaScriptValue>(data_->data.f_singleton_value));
  }
  bool is_object_id() const { return data_->tag == Tag::kObjectId; }
  int32_t object_id() const {
    CHECK(is_object_id());
    return data_->data.f_object_id;
  }

 private:
  internal::RemoteInvocationResultValue_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};



}  // blink::mojom

#endif  // THIRD_PARTY_BLINK_PUBLIC_MOJOM_REMOTE_OBJECTS_REMOTE_OBJECTS_MOJOM_DATA_VIEW_H_