// components/origin_matcher/origin_matcher.mojom-shared.h is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2016 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_SHARED_H_
#define COMPONENTS_ORIGIN_MATCHER_ORIGIN_MATCHER_MOJOM_SHARED_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/map_data_view.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "mojo/public/cpp/system/message_pipe.h"

#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"

#include "components/origin_matcher/origin_matcher.mojom-shared-internal.h"




#include "components/origin_matcher/origin_matcher.mojom-data-view.h"  // IWYU pragma: export




namespace std {

}  // namespace std

namespace mojo {


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::origin_matcher::mojom::SubdomainMatchingRuleDataView, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::origin_matcher::mojom::SubdomainMatchingRuleDataView, UserType>;

  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::origin_matcher::mojom::internal::SubdomainMatchingRule_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

    decltype(Traits::scheme(input)) in_scheme = Traits::scheme(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->scheme)::BaseType> scheme_fragment(
            fragment.message());
    
    mojo::internal::Serialize<mojo::StringDataView>(
      in_scheme,
      scheme_fragment);

    fragment->scheme.Set(
        scheme_fragment.is_null() ? nullptr : scheme_fragment.data());

    
    MOJO_INTERNAL_CHECK_SERIALIZATION(
      mojo::internal::SendValidation::kDefault,
      !(fragment->scheme.is_null()),
      mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
      "null scheme in SubdomainMatchingRule struct");

    decltype(Traits::optional_host(input)) in_optional_host = Traits::optional_host(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->optional_host)::BaseType> optional_host_fragment(
            fragment.message());
    
    mojo::internal::Serialize<mojo::StringDataView>(
      in_optional_host,
      optional_host_fragment);

    fragment->optional_host.Set(
        optional_host_fragment.is_null() ? nullptr : optional_host_fragment.data());

    
    MOJO_INTERNAL_CHECK_SERIALIZATION(
      mojo::internal::SendValidation::kDefault,
      !(fragment->optional_host.is_null()),
      mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
      "null optional_host in SubdomainMatchingRule struct");

    fragment->optional_port = Traits::optional_port(input);
  }

  static bool Deserialize(::origin_matcher::mojom::internal::SubdomainMatchingRule_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input)
      return CallSetToNullIfExists<Traits>(output);

    ::origin_matcher::mojom::SubdomainMatchingRuleDataView data_view(input, message);
    return CallTraitsRead<Traits>(data_view, output);
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::origin_matcher::mojom::OriginMatcherRuleDataView, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::origin_matcher::mojom::OriginMatcherRuleDataView, UserType>;

  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::origin_matcher::mojom::internal::OriginMatcherRule_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

    decltype(Traits::subdomain_matching_rule(input)) in_subdomain_matching_rule = Traits::subdomain_matching_rule(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->subdomain_matching_rule)::BaseType> subdomain_matching_rule_fragment(
            fragment.message());
    
    mojo::internal::Serialize<::origin_matcher::mojom::SubdomainMatchingRuleDataView>(
      in_subdomain_matching_rule,
      subdomain_matching_rule_fragment);

    fragment->subdomain_matching_rule.Set(
        subdomain_matching_rule_fragment.is_null() ? nullptr : subdomain_matching_rule_fragment.data());
  }

  static bool Deserialize(::origin_matcher::mojom::internal::OriginMatcherRule_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input)
      return CallSetToNullIfExists<Traits>(output);

    ::origin_matcher::mojom::OriginMatcherRuleDataView data_view(input, message);
    return CallTraitsRead<Traits>(data_view, output);
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::origin_matcher::mojom::OriginMatcherDataView, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::origin_matcher::mojom::OriginMatcherDataView, UserType>;

  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::origin_matcher::mojom::internal::OriginMatcher_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

    decltype(Traits::rules(input)) in_rules = Traits::rules(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->rules)::BaseType>
        rules_fragment(fragment.message());
    constexpr const mojo::internal::ContainerValidateParams& rules_validate_params =
        mojo::internal::GetArrayValidator<0, false, nullptr>();
    
    mojo::internal::Serialize<mojo::ArrayDataView<::origin_matcher::mojom::OriginMatcherRuleDataView>>(
      in_rules,
      rules_fragment,
      &rules_validate_params);

    fragment->rules.Set(
        rules_fragment.is_null() ? nullptr : rules_fragment.data());

    
    MOJO_INTERNAL_CHECK_SERIALIZATION(
      mojo::internal::SendValidation::kDefault,
      !(fragment->rules.is_null()),
      mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
      "null rules in OriginMatcher struct");
  }

  static bool Deserialize(::origin_matcher::mojom::internal::OriginMatcher_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input)
      return CallSetToNullIfExists<Traits>(output);

    ::origin_matcher::mojom::OriginMatcherDataView data_view(input, message);
    return CallTraitsRead<Traits>(data_view, output);
  }
};

}  // namespace internal

}  // namespace mojo


namespace origin_matcher::mojom {

inline void SubdomainMatchingRuleDataView::GetSchemeDataView(
    mojo::StringDataView* output) {
  auto pointer = data_->scheme.Get();
  *output = mojo::StringDataView(pointer, message_);
}
inline void SubdomainMatchingRuleDataView::GetOptionalHostDataView(
    mojo::StringDataView* output) {
  auto pointer = data_->optional_host.Get();
  *output = mojo::StringDataView(pointer, message_);
}


inline void OriginMatcherRuleDataView::GetSubdomainMatchingRuleDataView(
    SubdomainMatchingRuleDataView* output) {
  auto pointer = data_->subdomain_matching_rule.Get();
  *output = SubdomainMatchingRuleDataView(pointer, message_);
}


inline void OriginMatcherDataView::GetRulesDataView(
    mojo::ArrayDataView<OriginMatcherRuleDataView>* output) {
  auto pointer = data_->rules.Get();
  *output = mojo::ArrayDataView<OriginMatcherRuleDataView>(pointer, message_);
}



}  // origin_matcher::mojom

// Declare TraceFormatTraits for enums, which should be defined in ::perfetto
// namespace.

#endif  // COMPONENTS_ORIGIN_MATCHER_ORIGIN_MATCHER_MOJOM_SHARED_H_