// components/optimization_guide/public/mojom/model_broker_debug.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 COMPONENTS_OPTIMIZATION_GUIDE_PUBLIC_MOJOM_MODEL_BROKER_DEBUG_MOJOM_DATA_VIEW_H_
#define COMPONENTS_OPTIMIZATION_GUIDE_PUBLIC_MOJOM_MODEL_BROKER_DEBUG_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 "components/optimization_guide/public/mojom/model_broker_debug.mojom-shared-internal.h"
#include "components/optimization_guide/public/mojom/model_broker.mojom-shared.h"
#include "mojo/public/mojom/base/proto_wrapper.mojom-shared.h"
#include "services/on_device_model/public/mojom/download_observer.mojom-shared.h"
#include "services/on_device_model/public/mojom/on_device_model.mojom-shared.h"


namespace optimization_guide::mojom {
class BrokerPropertyInfoDataView;

class BrokerAssetInfoDataView;

class BrokerUseCaseInfoDataView;

class BrokerModelInfoDataView;

class BrokerStateInfoDataView;



}  // optimization_guide::mojom


namespace mojo {
namespace internal {

template <>
struct MojomTypeTraits<::optimization_guide::mojom::BrokerPropertyInfoDataView> {
  using Data = ::optimization_guide::mojom::internal::BrokerPropertyInfo_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

template <>
struct MojomTypeTraits<::optimization_guide::mojom::BrokerAssetInfoDataView> {
  using Data = ::optimization_guide::mojom::internal::BrokerAssetInfo_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

template <>
struct MojomTypeTraits<::optimization_guide::mojom::BrokerUseCaseInfoDataView> {
  using Data = ::optimization_guide::mojom::internal::BrokerUseCaseInfo_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

template <>
struct MojomTypeTraits<::optimization_guide::mojom::BrokerModelInfoDataView> {
  using Data = ::optimization_guide::mojom::internal::BrokerModelInfo_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

template <>
struct MojomTypeTraits<::optimization_guide::mojom::BrokerStateInfoDataView> {
  using Data = ::optimization_guide::mojom::internal::BrokerStateInfo_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

}  // namespace internal
}  // namespace mojo


namespace optimization_guide::mojom {


enum class BrokerAssetState : int32_t {
  
  kNotInstalled = 0,
  
  kRegistering = 1,
  
  kBackgroundInstalling = 2,
  
  kForegroundInstalling = 3,
  
  kReady = 4,
  
  kUninstalling = 5,
  kMinValue = 0,
  kMaxValue = 5,
};

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

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

using ModelBrokerDebugObserverPtrDataView =
    mojo::InterfacePtrDataView<ModelBrokerDebugObserverInterfaceBase>;
using ModelBrokerDebugObserverRequestDataView =
    mojo::InterfaceRequestDataView<ModelBrokerDebugObserverInterfaceBase>;
using ModelBrokerDebugObserverAssociatedPtrInfoDataView =
    mojo::AssociatedInterfacePtrInfoDataView<ModelBrokerDebugObserverInterfaceBase>;
using ModelBrokerDebugObserverAssociatedRequestDataView =
    mojo::AssociatedInterfaceRequestDataView<ModelBrokerDebugObserverInterfaceBase>;
class ModelBrokerDebugInterfaceBase {};

using ModelBrokerDebugPtrDataView =
    mojo::InterfacePtrDataView<ModelBrokerDebugInterfaceBase>;
using ModelBrokerDebugRequestDataView =
    mojo::InterfaceRequestDataView<ModelBrokerDebugInterfaceBase>;
using ModelBrokerDebugAssociatedPtrInfoDataView =
    mojo::AssociatedInterfacePtrInfoDataView<ModelBrokerDebugInterfaceBase>;
using ModelBrokerDebugAssociatedRequestDataView =
    mojo::AssociatedInterfaceRequestDataView<ModelBrokerDebugInterfaceBase>;


class BrokerPropertyInfoDataView {
 public:
  BrokerPropertyInfoDataView() = default;

  BrokerPropertyInfoDataView(
      internal::BrokerPropertyInfo_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  inline void GetDescriptionDataView(
      mojo::StringDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadDescription(UserType* output) {
    
    auto* pointer = data_->description.Get();
    return mojo::internal::Deserialize<mojo::StringDataView>(
        pointer, output, message_);
  }
  inline void GetValueDataView(
      mojo::StringDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadValue(UserType* output) {
    
    auto* pointer = data_->value.Get();
    return mojo::internal::Deserialize<mojo::StringDataView>(
        pointer, output, message_);
  }
 private:
  internal::BrokerPropertyInfo_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


class BrokerAssetInfoDataView {
 public:
  BrokerAssetInfoDataView() = default;

  BrokerAssetInfoDataView(
      internal::BrokerAssetInfo_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  inline void GetNameDataView(
      mojo::StringDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadName(UserType* output) {
    
    auto* pointer = data_->name.Get();
    return mojo::internal::Deserialize<mojo::StringDataView>(
        pointer, output, message_);
  }
  inline void GetVersionDataView(
      mojo::StringDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadVersion(UserType* output) {
    
static_assert(
    mojo::internal::IsValidUserTypeForOptionalValue<
        mojo::StringDataView, UserType>(),
    "Attempting to read the optional `version` 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 `MaybeReadVersion` instead "
    "of `ReadVersion if you're fine with null values being "
    "silently ignored in this case.");
    auto* pointer = data_->version.Get();
    return mojo::internal::Deserialize<mojo::StringDataView>(
        pointer, output, message_);
  }
  template <typename UserType>
  [[nodiscard]] bool ReadState(UserType* output) const {
    auto data_value = data_->state;
    return mojo::internal::Deserialize<::optimization_guide::mojom::BrokerAssetState>(
        data_value, output);
  }
  BrokerAssetState state() const {
    return ::mojo::internal::ToKnownEnumValueHelper(
          static_cast<::optimization_guide::mojom::BrokerAssetState>(data_->state));
  }
  inline void GetErrorDataView(
      mojo::StringDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadError(UserType* output) {
    
static_assert(
    mojo::internal::IsValidUserTypeForOptionalValue<
        mojo::StringDataView, UserType>(),
    "Attempting to read the optional `error` 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 `MaybeReadError` instead "
    "of `ReadError if you're fine with null values being "
    "silently ignored in this case.");
    auto* pointer = data_->error.Get();
    return mojo::internal::Deserialize<mojo::StringDataView>(
        pointer, output, message_);
  }
  uint64_t bytes_downloaded() const {
    return data_->bytes_downloaded;
  }
  uint64_t bytes_total() const {
    return data_->bytes_total;
  }
 private:
  internal::BrokerAssetInfo_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


class BrokerUseCaseInfoDataView {
 public:
  BrokerUseCaseInfoDataView() = default;

  BrokerUseCaseInfoDataView(
      internal::BrokerUseCaseInfo_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  inline void GetNameDataView(
      mojo::StringDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadName(UserType* output) {
    
    auto* pointer = data_->name.Get();
    return mojo::internal::Deserialize<mojo::StringDataView>(
        pointer, output, message_);
  }
  bool assets_requested() const {
    return data_->assets_requested;
  }
  template <typename UserType>
  [[nodiscard]] bool ReadUnavailableReason(UserType* output) const {
    if (!data_->unavailable_reason_$flag) {
      *output = std::nullopt;
      return true;
    }

    return mojo::internal::Deserialize<::optimization_guide::mojom::ModelUnavailableReason>(
        data_->unavailable_reason_$value, &output->emplace());
  }
  std::optional<::optimization_guide::mojom::ModelUnavailableReason> unavailable_reason() const {
    if (!data_->unavailable_reason_$flag) {
      return std::nullopt;
    }
    return ::mojo::internal::ToKnownEnumValueHelper(
          static_cast<::optimization_guide::mojom::ModelUnavailableReason>(data_->unavailable_reason_$value));
  }
 private:
  internal::BrokerUseCaseInfo_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


class BrokerModelInfoDataView {
 public:
  BrokerModelInfoDataView() = default;

  BrokerModelInfoDataView(
      internal::BrokerModelInfo_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  inline void GetNameDataView(
      mojo::StringDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadName(UserType* output) {
    
    auto* pointer = data_->name.Get();
    return mojo::internal::Deserialize<mojo::StringDataView>(
        pointer, output, message_);
  }
  uint64_t folder_size() const {
    return data_->folder_size;
  }
  inline void GetWeightsPathDataView(
      mojo::StringDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadWeightsPath(UserType* output) {
    
    auto* pointer = data_->weights_path.Get();
    return mojo::internal::Deserialize<mojo::StringDataView>(
        pointer, output, message_);
  }
  inline void GetBackendTypeDataView(
      mojo::StringDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadBackendType(UserType* output) {
    
    auto* pointer = data_->backend_type.Get();
    return mojo::internal::Deserialize<mojo::StringDataView>(
        pointer, output, message_);
  }
 private:
  internal::BrokerModelInfo_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


class BrokerStateInfoDataView {
 public:
  BrokerStateInfoDataView() = default;

  BrokerStateInfoDataView(
      internal::BrokerStateInfo_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  inline void GetPropertiesDataView(
      mojo::ArrayDataView<BrokerPropertyInfoDataView>* output);

  template <typename UserType>
  [[nodiscard]] bool ReadProperties(UserType* output) {
    
    auto* pointer = data_->properties.Get();
    return mojo::internal::Deserialize<mojo::ArrayDataView<::optimization_guide::mojom::BrokerPropertyInfoDataView>>(
        pointer, output, message_);
  }
  inline void GetAssetsDataView(
      mojo::ArrayDataView<BrokerAssetInfoDataView>* output);

  template <typename UserType>
  [[nodiscard]] bool ReadAssets(UserType* output) {
    
    auto* pointer = data_->assets.Get();
    return mojo::internal::Deserialize<mojo::ArrayDataView<::optimization_guide::mojom::BrokerAssetInfoDataView>>(
        pointer, output, message_);
  }
  inline void GetUseCasesDataView(
      mojo::ArrayDataView<BrokerUseCaseInfoDataView>* output);

  template <typename UserType>
  [[nodiscard]] bool ReadUseCases(UserType* output) {
    
    auto* pointer = data_->use_cases.Get();
    return mojo::internal::Deserialize<mojo::ArrayDataView<::optimization_guide::mojom::BrokerUseCaseInfoDataView>>(
        pointer, output, message_);
  }
  inline void GetModelsDataView(
      mojo::ArrayDataView<BrokerModelInfoDataView>* output);

  template <typename UserType>
  [[nodiscard]] bool ReadModels(UserType* output) {
    
    auto* pointer = data_->models.Get();
    return mojo::internal::Deserialize<mojo::ArrayDataView<::optimization_guide::mojom::BrokerModelInfoDataView>>(
        pointer, output, message_);
  }
  std::optional<int32_t> model_crash_count() const {

    return data_->model_crash_count_$flag
        ? std::make_optional(data_->model_crash_count_$value)
        : std::nullopt;
  }
  std::optional<int32_t> max_model_crash_count() const {

    return data_->max_model_crash_count_$flag
        ? std::make_optional(data_->max_model_crash_count_$value)
        : std::nullopt;
  }
  bool is_asset_manager_initialized() const {
    return data_->is_asset_manager_initialized;
  }
 private:
  internal::BrokerStateInfo_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


}  // optimization_guide::mojom

#endif  // COMPONENTS_OPTIMIZATION_GUIDE_PUBLIC_MOJOM_MODEL_BROKER_DEBUG_MOJOM_DATA_VIEW_H_