// ui/accessibility/mojom/ax_tree_id.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 UI_ACCESSIBILITY_MOJOM_AX_TREE_ID_MOJOM_DATA_VIEW_H_
#define UI_ACCESSIBILITY_MOJOM_AX_TREE_ID_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 "ui/accessibility/mojom/ax_tree_id.mojom-shared-internal.h"
#include "ui/accessibility/ax_enums.mojom-shared.h"
#include "mojo/public/mojom/base/unguessable_token.mojom-shared.h"


namespace ax::mojom {
class AXTreeIDDataView;


}  // ax::mojom


namespace mojo {
namespace internal {

template <>
struct MojomTypeTraits<::ax::mojom::AXTreeIDDataView> {
  using Data = ::ax::mojom::internal::AXTreeID_Data;
  using DataAsArrayElement = Data;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kUnion;
};

}  // namespace internal
}  // namespace mojo


namespace ax::mojom {


class AXTreeIDDataView {
 public:
  using Tag = internal::AXTreeID_Data::AXTreeID_Tag;

  AXTreeIDDataView() = default;

  AXTreeIDDataView(
      internal::AXTreeID_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const {
    // For inlined unions, |data_| is always non-null. In that case we need to
    // check |data_->is_null()|.
    return !data_ || data_->is_null();
  }

  Tag tag() const { return data_->tag; }
  bool is_unknown() const { return data_->tag == Tag::kUnknown; }
  uint8_t unknown() const {
    CHECK(is_unknown());
    return data_->data.f_unknown;
  }
  bool is_token() const { return data_->tag == Tag::kToken; }
  inline void GetTokenDataView(
      ::mojo_base::mojom::UnguessableTokenDataView* output) const;

  template <typename UserType>
  [[nodiscard]] bool ReadToken(UserType* output) const {
    
    CHECK(is_token());
    return mojo::internal::Deserialize<::mojo_base::mojom::UnguessableTokenDataView>(
        data_->data.f_token.Get(), output, message_);
  }

 private:
  internal::AXTreeID_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};



}  // ax::mojom

#endif  // UI_ACCESSIBILITY_MOJOM_AX_TREE_ID_MOJOM_DATA_VIEW_H_