// third_party/blink/public/mojom/serial/serial.mojom-send-validation.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.

#ifndef THIRD_PARTY_BLINK_PUBLIC_MOJOM_SERIAL_SERIAL_MOJOM_SEND_VALIDATION_H_
#define THIRD_PARTY_BLINK_PUBLIC_MOJOM_SERIAL_SERIAL_MOJOM_SEND_VALIDATION_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"

#include "third_party/blink/public/mojom/serial/serial.mojom-data-view.h"

#include "mojo/public/cpp/bindings/lib/send_validation_type.h"
#include "mojo/public/cpp/bindings/lib/send_validation.h"
#include "mojo/public/cpp/bindings/lib/interface_serialization_send_validation.h"

namespace mojo::internal {

template <typename MaybeConstUserType, mojo::internal::SendValidation send_validation>
struct SendValidationSerializer<::blink::mojom::SerialPortInfoDataView, MaybeConstUserType, send_validation> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::blink::mojom::SerialPortInfoDataView, UserType>;
  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::blink::mojom::internal::SerialPortInfo_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

      decltype(Traits::token(input)) in_token = Traits::token(input);
      mojo::internal::MessageFragment<
          typename decltype(fragment->token)::BaseType> token_fragment(
              fragment.message());
      
      mojo::internal::Serialize<::mojo_base::mojom::UnguessableTokenDataView, send_validation>(
        in_token,
        token_fragment);

      fragment->token.Set(
          token_fragment.is_null() ? nullptr : token_fragment.data());

      
      MOJO_INTERNAL_CHECK_SERIALIZATION(
        send_validation,
        !(fragment->token.is_null()),
        mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
        "null token in SerialPortInfo struct");

      fragment->usb_vendor_id = Traits::usb_vendor_id(input);

      fragment->has_usb_vendor_id = Traits::has_usb_vendor_id(input);

      fragment->usb_product_id = Traits::usb_product_id(input);

      fragment->has_usb_product_id = Traits::has_usb_product_id(input);

      decltype(Traits::bluetooth_service_class_id(input)) in_bluetooth_service_class_id = Traits::bluetooth_service_class_id(input);
      mojo::internal::MessageFragment<
          typename decltype(fragment->bluetooth_service_class_id)::BaseType> bluetooth_service_class_id_fragment(
              fragment.message());
      
      mojo::internal::Serialize<::bluetooth::mojom::UUIDDataView, send_validation>(
        in_bluetooth_service_class_id,
        bluetooth_service_class_id_fragment);

      fragment->bluetooth_service_class_id.Set(
          bluetooth_service_class_id_fragment.is_null() ? nullptr : bluetooth_service_class_id_fragment.data());

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

template <typename MaybeConstUserType, mojo::internal::SendValidation send_validation>
struct SendValidationSerializer<::blink::mojom::SerialPortFilterDataView, MaybeConstUserType, send_validation> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::blink::mojom::SerialPortFilterDataView, UserType>;
  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::blink::mojom::internal::SerialPortFilter_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

      fragment->vendor_id = Traits::vendor_id(input);

      fragment->has_vendor_id = Traits::has_vendor_id(input);

      fragment->product_id = Traits::product_id(input);

      fragment->has_product_id = Traits::has_product_id(input);

      decltype(Traits::bluetooth_service_class_id(input)) in_bluetooth_service_class_id = Traits::bluetooth_service_class_id(input);
      mojo::internal::MessageFragment<
          typename decltype(fragment->bluetooth_service_class_id)::BaseType> bluetooth_service_class_id_fragment(
              fragment.message());
      
      mojo::internal::Serialize<::bluetooth::mojom::UUIDDataView, send_validation>(
        in_bluetooth_service_class_id,
        bluetooth_service_class_id_fragment);

      fragment->bluetooth_service_class_id.Set(
          bluetooth_service_class_id_fragment.is_null() ? nullptr : bluetooth_service_class_id_fragment.data());
  }
};

}  // namespace mojo::internal

#endif  // THIRD_PARTY_BLINK_PUBLIC_MOJOM_SERIAL_SERIAL_MOJOM_SEND_VALIDATION_H_