// services/on_device_model/android/downloader_params.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_ON_DEVICE_MODEL_ANDROID_DOWNLOADER_PARAMS_MOJOM_H_
#define SERVICES_ON_DEVICE_MODEL_ANDROID_DOWNLOADER_PARAMS_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/on_device_model/android/downloader_params.mojom-features.h"  // IWYU pragma: export
#include "services/on_device_model/android/downloader_params.mojom-shared.h"  // IWYU pragma: export
#include "services/on_device_model/android/downloader_params.mojom-forward.h"  // IWYU pragma: export
#include <string>
#include <vector>








namespace on_device_model::mojom {





class  DownloaderParams {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<DownloaderParams, T>::value>;
  using DataView = DownloaderParamsDataView;
  using Data_ = internal::DownloaderParams_Data;

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

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

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


  DownloaderParams();

  explicit DownloaderParams(
      bool require_persistent_mode);


  ~DownloaderParams();

  // 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 = DownloaderParamsPtr>
  DownloaderParamsPtr 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, DownloaderParams::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

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

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

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

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

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        DownloaderParams::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::DownloaderParams_UnserializedMessageContext<
            UserType, DownloaderParams::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<DownloaderParams::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return DownloaderParams::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::DownloaderParams_UnserializedMessageContext<
            UserType, DownloaderParams::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<DownloaderParams::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  bool require_persistent_mode;

  // 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, DownloaderParams::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

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

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

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




template <typename StructPtrType>
DownloaderParamsPtr DownloaderParams::Clone() const {
  return New(
      mojo::Clone(require_persistent_mode)
  );
}

template <typename T, DownloaderParams::EnableIfSame<T>*>
bool DownloaderParams::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->require_persistent_mode, other_struct.require_persistent_mode))
    return false;
  return true;
}

template <typename T, DownloaderParams::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.require_persistent_mode < rhs.require_persistent_mode)
    return true;
  if (rhs.require_persistent_mode < lhs.require_persistent_mode)
    return false;
  return false;
}


}  // on_device_model::mojom

namespace mojo {


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

  static decltype(::on_device_model::mojom::DownloaderParams::require_persistent_mode) require_persistent_mode(
      const ::on_device_model::mojom::DownloaderParamsPtr& input) {
    return input->require_persistent_mode;
  }

  static bool Read(::on_device_model::mojom::DownloaderParams::DataView input, ::on_device_model::mojom::DownloaderParamsPtr* output);
};

}  // namespace mojo

#endif  // SERVICES_ON_DEVICE_MODEL_ANDROID_DOWNLOADER_PARAMS_MOJOM_H_