// third_party/blink/public/mojom/serial/serial.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 THIRD_PARTY_BLINK_PUBLIC_MOJOM_SERIAL_SERIAL_MOJOM_DATA_VIEW_H_
#define THIRD_PARTY_BLINK_PUBLIC_MOJOM_SERIAL_SERIAL_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 "third_party/blink/public/mojom/serial/serial.mojom-shared-internal.h"
#include "device/bluetooth/public/mojom/uuid.mojom-shared.h"
#include "mojo/public/mojom/base/unguessable_token.mojom-shared.h"
#include "services/device/public/mojom/serial.mojom-shared.h"


namespace blink::mojom {
class SerialPortInfoDataView;

class SerialPortFilterDataView;



}  // blink::mojom


namespace mojo {
namespace internal {

template <>
struct MojomTypeTraits<::blink::mojom::SerialPortInfoDataView> {
  using Data = ::blink::mojom::internal::SerialPortInfo_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

template <>
struct MojomTypeTraits<::blink::mojom::SerialPortFilterDataView> {
  using Data = ::blink::mojom::internal::SerialPortFilter_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

}  // namespace internal
}  // namespace mojo


namespace blink::mojom {
// Interface base classes. They are used for type safety check.
class SerialServiceInterfaceBase {};

using SerialServicePtrDataView =
    mojo::InterfacePtrDataView<SerialServiceInterfaceBase>;
using SerialServiceRequestDataView =
    mojo::InterfaceRequestDataView<SerialServiceInterfaceBase>;
using SerialServiceAssociatedPtrInfoDataView =
    mojo::AssociatedInterfacePtrInfoDataView<SerialServiceInterfaceBase>;
using SerialServiceAssociatedRequestDataView =
    mojo::AssociatedInterfaceRequestDataView<SerialServiceInterfaceBase>;
class SerialServiceClientInterfaceBase {};

using SerialServiceClientPtrDataView =
    mojo::InterfacePtrDataView<SerialServiceClientInterfaceBase>;
using SerialServiceClientRequestDataView =
    mojo::InterfaceRequestDataView<SerialServiceClientInterfaceBase>;
using SerialServiceClientAssociatedPtrInfoDataView =
    mojo::AssociatedInterfacePtrInfoDataView<SerialServiceClientInterfaceBase>;
using SerialServiceClientAssociatedRequestDataView =
    mojo::AssociatedInterfaceRequestDataView<SerialServiceClientInterfaceBase>;


class SerialPortInfoDataView {
 public:
  SerialPortInfoDataView() = default;

  SerialPortInfoDataView(
      internal::SerialPortInfo_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  inline void GetTokenDataView(
      ::mojo_base::mojom::UnguessableTokenDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadToken(UserType* output) {
    
    auto* pointer = data_->token.Get();
    return mojo::internal::Deserialize<::mojo_base::mojom::UnguessableTokenDataView>(
        pointer, output, message_);
  }
  uint16_t usb_vendor_id() const {
    return data_->usb_vendor_id;
  }
  bool has_usb_vendor_id() const {
    return data_->has_usb_vendor_id;
  }
  uint16_t usb_product_id() const {
    return data_->usb_product_id;
  }
  bool has_usb_product_id() const {
    return data_->has_usb_product_id;
  }
  inline void GetBluetoothServiceClassIdDataView(
      ::bluetooth::mojom::UUIDDataView* output);

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


class SerialPortFilterDataView {
 public:
  SerialPortFilterDataView() = default;

  SerialPortFilterDataView(
      internal::SerialPortFilter_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  uint32_t vendor_id() const {
    return data_->vendor_id;
  }
  bool has_vendor_id() const {
    return data_->has_vendor_id;
  }
  uint16_t product_id() const {
    return data_->product_id;
  }
  bool has_product_id() const {
    return data_->has_product_id;
  }
  inline void GetBluetoothServiceClassIdDataView(
      ::bluetooth::mojom::UUIDDataView* output);

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


}  // blink::mojom

#endif  // THIRD_PARTY_BLINK_PUBLIC_MOJOM_SERIAL_SERIAL_MOJOM_DATA_VIEW_H_