// components/origin_matcher/origin_matcher.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_ORIGIN_MATCHER_ORIGIN_MATCHER_MOJOM_DATA_VIEW_H_
#define COMPONENTS_ORIGIN_MATCHER_ORIGIN_MATCHER_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/origin_matcher/origin_matcher.mojom-shared-internal.h"


namespace origin_matcher::mojom {
class SubdomainMatchingRuleDataView;

class OriginMatcherRuleDataView;

class OriginMatcherDataView;



}  // origin_matcher::mojom


namespace mojo {
namespace internal {

template <>
struct MojomTypeTraits<::origin_matcher::mojom::SubdomainMatchingRuleDataView> {
  using Data = ::origin_matcher::mojom::internal::SubdomainMatchingRule_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

template <>
struct MojomTypeTraits<::origin_matcher::mojom::OriginMatcherRuleDataView> {
  using Data = ::origin_matcher::mojom::internal::OriginMatcherRule_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

template <>
struct MojomTypeTraits<::origin_matcher::mojom::OriginMatcherDataView> {
  using Data = ::origin_matcher::mojom::internal::OriginMatcher_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

}  // namespace internal
}  // namespace mojo


namespace origin_matcher::mojom {


class SubdomainMatchingRuleDataView {
 public:
  SubdomainMatchingRuleDataView() = default;

  SubdomainMatchingRuleDataView(
      internal::SubdomainMatchingRule_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

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

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

  template <typename UserType>
  [[nodiscard]] bool ReadOptionalHost(UserType* output) {
    
    auto* pointer = data_->optional_host.Get();
    return mojo::internal::Deserialize<mojo::StringDataView>(
        pointer, output, message_);
  }
  int32_t optional_port() const {
    return data_->optional_port;
  }
 private:
  internal::SubdomainMatchingRule_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


class OriginMatcherRuleDataView {
 public:
  OriginMatcherRuleDataView() = default;

  OriginMatcherRuleDataView(
      internal::OriginMatcherRule_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  inline void GetSubdomainMatchingRuleDataView(
      SubdomainMatchingRuleDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadSubdomainMatchingRule(UserType* output) {
    
static_assert(
    mojo::internal::IsValidUserTypeForOptionalValue<
        ::origin_matcher::mojom::SubdomainMatchingRuleDataView, UserType>(),
    "Attempting to read the optional `subdomain_matching_rule` 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 `MaybeReadSubdomainMatchingRule` instead "
    "of `ReadSubdomainMatchingRule if you're fine with null values being "
    "silently ignored in this case.");
    auto* pointer = data_->subdomain_matching_rule.Get();
    return mojo::internal::Deserialize<::origin_matcher::mojom::SubdomainMatchingRuleDataView>(
        pointer, output, message_);
  }
 private:
  internal::OriginMatcherRule_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


class OriginMatcherDataView {
 public:
  OriginMatcherDataView() = default;

  OriginMatcherDataView(
      internal::OriginMatcher_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

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

  template <typename UserType>
  [[nodiscard]] bool ReadRules(UserType* output) {
    
    auto* pointer = data_->rules.Get();
    return mojo::internal::Deserialize<mojo::ArrayDataView<::origin_matcher::mojom::OriginMatcherRuleDataView>>(
        pointer, output, message_);
  }
 private:
  internal::OriginMatcher_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


}  // origin_matcher::mojom

#endif  // COMPONENTS_ORIGIN_MATCHER_ORIGIN_MATCHER_MOJOM_DATA_VIEW_H_