// components/origin_matcher/origin_matcher.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 COMPONENTS_ORIGIN_MATCHER_ORIGIN_MATCHER_MOJOM_H_
#define COMPONENTS_ORIGIN_MATCHER_ORIGIN_MATCHER_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 "components/origin_matcher/origin_matcher.mojom-features.h"  // IWYU pragma: export
#include "components/origin_matcher/origin_matcher.mojom-shared.h"  // IWYU pragma: export
#include "components/origin_matcher/origin_matcher.mojom-forward.h"  // IWYU pragma: export
#include <string>
#include <vector>




#include "components/origin_matcher/origin_matcher.h"
#include "components/origin_matcher/origin_matcher_mojom_traits.h"




namespace origin_matcher::mojom {





class  SubdomainMatchingRule {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<SubdomainMatchingRule, T>::value>;
  using DataView = SubdomainMatchingRuleDataView;
  using Data_ = internal::SubdomainMatchingRule_Data;

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

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

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


  SubdomainMatchingRule();

  SubdomainMatchingRule(
      const std::string& scheme,
      const std::string& optional_host,
      int32_t optional_port);


  ~SubdomainMatchingRule();

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

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

  template <typename T, SubdomainMatchingRule::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<
        SubdomainMatchingRule::DataView, std::vector<uint8_t>, send_validation>(input);
  }

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

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

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

  
  std::string scheme;
  
  std::string optional_host;
  
  int32_t optional_port;

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

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

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

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










class  OriginMatcherRule {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<OriginMatcherRule, T>::value>;
  using DataView = OriginMatcherRuleDataView;
  using Data_ = internal::OriginMatcherRule_Data;

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

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

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


  OriginMatcherRule();

  explicit OriginMatcherRule(
      SubdomainMatchingRulePtr subdomain_matching_rule);

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

  ~OriginMatcherRule();

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

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

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

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

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

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

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

  
  SubdomainMatchingRulePtr subdomain_matching_rule;

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

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

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

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





class  OriginMatcher {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<OriginMatcher, T>::value>;
  using DataView = OriginMatcherDataView;
  using Data_ = internal::OriginMatcher_Data;

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

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

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


  OriginMatcher();

  explicit OriginMatcher(
      std::vector<::std::unique_ptr<::origin_matcher::OriginMatcherRule>> rules);

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

  ~OriginMatcher();

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

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

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

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

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

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

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

  
  std::vector<::std::unique_ptr<::origin_matcher::OriginMatcherRule>> rules;

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

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

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

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

template <typename StructPtrType>
SubdomainMatchingRulePtr SubdomainMatchingRule::Clone() const {
  return New(
      mojo::Clone(scheme),
      mojo::Clone(optional_host),
      mojo::Clone(optional_port)
  );
}

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

template <typename T, SubdomainMatchingRule::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.scheme < rhs.scheme)
    return true;
  if (rhs.scheme < lhs.scheme)
    return false;
  if (lhs.optional_host < rhs.optional_host)
    return true;
  if (rhs.optional_host < lhs.optional_host)
    return false;
  if (lhs.optional_port < rhs.optional_port)
    return true;
  if (rhs.optional_port < lhs.optional_port)
    return false;
  return false;
}
template <typename StructPtrType>
OriginMatcherRulePtr OriginMatcherRule::Clone() const {
  return New(
      mojo::Clone(subdomain_matching_rule)
  );
}

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

template <typename T, OriginMatcherRule::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.subdomain_matching_rule < rhs.subdomain_matching_rule)
    return true;
  if (rhs.subdomain_matching_rule < lhs.subdomain_matching_rule)
    return false;
  return false;
}
template <typename StructPtrType>
OriginMatcherPtr OriginMatcher::Clone() const {
  return New(
      mojo::Clone(rules)
  );
}

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

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


}  // origin_matcher::mojom

namespace mojo {


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

  static const decltype(::origin_matcher::mojom::SubdomainMatchingRule::scheme)& scheme(
      const ::origin_matcher::mojom::SubdomainMatchingRulePtr& input) {
    return input->scheme;
  }

  static const decltype(::origin_matcher::mojom::SubdomainMatchingRule::optional_host)& optional_host(
      const ::origin_matcher::mojom::SubdomainMatchingRulePtr& input) {
    return input->optional_host;
  }

  static decltype(::origin_matcher::mojom::SubdomainMatchingRule::optional_port) optional_port(
      const ::origin_matcher::mojom::SubdomainMatchingRulePtr& input) {
    return input->optional_port;
  }

  static bool Read(::origin_matcher::mojom::SubdomainMatchingRule::DataView input, ::origin_matcher::mojom::SubdomainMatchingRulePtr* output);
};


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

  static const decltype(::origin_matcher::mojom::OriginMatcherRule::subdomain_matching_rule)& subdomain_matching_rule(
      const ::origin_matcher::mojom::OriginMatcherRulePtr& input) {
    return input->subdomain_matching_rule;
  }

  static bool Read(::origin_matcher::mojom::OriginMatcherRule::DataView input, ::origin_matcher::mojom::OriginMatcherRulePtr* output);
};


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

  static const decltype(::origin_matcher::mojom::OriginMatcher::rules)& rules(
      const ::origin_matcher::mojom::OriginMatcherPtr& input) {
    return input->rules;
  }

  static bool Read(::origin_matcher::mojom::OriginMatcher::DataView input, ::origin_matcher::mojom::OriginMatcherPtr* output);
};

}  // namespace mojo

#endif  // COMPONENTS_ORIGIN_MATCHER_ORIGIN_MATCHER_MOJOM_H_