// components/persistent_cache/mojom/persistent_cache.mojom-blink.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 COMPONENTS_PERSISTENT_CACHE_MOJOM_PERSISTENT_CACHE_MOJOM_BLINK_H_
#define COMPONENTS_PERSISTENT_CACHE_MOJOM_PERSISTENT_CACHE_MOJOM_BLINK_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 "components/persistent_cache/mojom/persistent_cache.mojom-features.h"  // IWYU pragma: export
#include "components/persistent_cache/mojom/persistent_cache.mojom-shared.h"  // IWYU pragma: export
#include "components/persistent_cache/mojom/persistent_cache.mojom-blink-forward.h"  // IWYU pragma: export
#include "components/sqlite_vfs/mojom/sqlite_vfs.mojom-blink.h"

#include "mojo/public/cpp/bindings/lib/wtf_clone_equals_util.h"
#include "mojo/public/cpp/bindings/lib/wtf_hash_util.h"
#include "third_party/blink/renderer/platform/wtf/hash_functions.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"

#include "mojo/public/cpp/bindings/lib/control_message_handler.h"
#include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h"


#include "components/persistent_cache/mojom/persistent_cache_mojom_traits.h"
#if !BLINK_MOJO_IMPL && !INSIDE_BLINK
#error "File must only be imported inside blink"
#endif


namespace sqlite_vfs { struct PendingFileSet; }
namespace sqlite_vfs { struct PendingFileSet; }


namespace persistent_cache::mojom::blink {









class  PendingReadOnlyBackend {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<PendingReadOnlyBackend, T>::value>;
  using DataView = PendingReadOnlyBackendDataView;
  using Data_ = internal::PendingReadOnlyBackend_Data;

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

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

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


  PendingReadOnlyBackend();

  explicit PendingReadOnlyBackend(
      ::sqlite_vfs::PendingFileSet pending_file_set);

PendingReadOnlyBackend(const PendingReadOnlyBackend&) = delete;
PendingReadOnlyBackend& operator=(const PendingReadOnlyBackend&) = delete;

  ~PendingReadOnlyBackend();

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

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

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

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

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

  
  ::sqlite_vfs::PendingFileSet pending_file_set;

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

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

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

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





class  PendingReadWriteBackend {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<PendingReadWriteBackend, T>::value>;
  using DataView = PendingReadWriteBackendDataView;
  using Data_ = internal::PendingReadWriteBackend_Data;

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

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

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


  PendingReadWriteBackend();

  explicit PendingReadWriteBackend(
      ::sqlite_vfs::PendingFileSet pending_file_set);

PendingReadWriteBackend(const PendingReadWriteBackend&) = delete;
PendingReadWriteBackend& operator=(const PendingReadWriteBackend&) = delete;

  ~PendingReadWriteBackend();

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

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

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

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

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

  
  ::sqlite_vfs::PendingFileSet pending_file_set;

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

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

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

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

template <typename StructPtrType>
PendingReadOnlyBackendPtr PendingReadOnlyBackend::Clone() const {
  return New(
      mojo::Clone(pending_file_set)
  );
}

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

template <typename T, PendingReadOnlyBackend::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.pending_file_set < rhs.pending_file_set)
    return true;
  if (rhs.pending_file_set < lhs.pending_file_set)
    return false;
  return false;
}
template <typename StructPtrType>
PendingReadWriteBackendPtr PendingReadWriteBackend::Clone() const {
  return New(
      mojo::Clone(pending_file_set)
  );
}

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

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


}  // persistent_cache::mojom::blink

namespace mojo {


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

  static  decltype(::persistent_cache::mojom::blink::PendingReadOnlyBackend::pending_file_set)& pending_file_set(
       ::persistent_cache::mojom::blink::PendingReadOnlyBackendPtr& input) {
    return input->pending_file_set;
  }

  static bool Read(::persistent_cache::mojom::blink::PendingReadOnlyBackend::DataView input, ::persistent_cache::mojom::blink::PendingReadOnlyBackendPtr* output);
};


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

  static  decltype(::persistent_cache::mojom::blink::PendingReadWriteBackend::pending_file_set)& pending_file_set(
       ::persistent_cache::mojom::blink::PendingReadWriteBackendPtr& input) {
    return input->pending_file_set;
  }

  static bool Read(::persistent_cache::mojom::blink::PendingReadWriteBackend::DataView input, ::persistent_cache::mojom::blink::PendingReadWriteBackendPtr* output);
};

}  // namespace mojo

#endif  // COMPONENTS_PERSISTENT_CACHE_MOJOM_PERSISTENT_CACHE_MOJOM_BLINK_H_