// ipc/ipc.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 IPC_IPC_MOJOM_SEND_VALIDATION_H_
#define IPC_IPC_MOJOM_SEND_VALIDATION_H_

#include "ipc/ipc.mojom-shared-internal.h"
#include "mojo/public/interfaces/bindings/native_struct.mojom-shared.h"
#include "mojo/public/mojom/base/generic_pending_associated_receiver.mojom-shared.h"

#include "ipc/ipc.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<::IPC::mojom::MessageDataView, MaybeConstUserType, send_validation> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::IPC::mojom::MessageDataView, UserType>;
  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::IPC::mojom::internal::Message_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

      decltype(Traits::bytes(input)) in_bytes = Traits::bytes(input);
      mojo::internal::MessageFragment<
          typename decltype(fragment->bytes)::BaseType>
          bytes_fragment(fragment.message());
      constexpr const mojo::internal::ContainerValidateParams& bytes_validate_params =
          mojo::internal::GetArrayValidator<0, false, nullptr>();
      
      mojo::internal::Serialize<mojo::ArrayDataView<uint8_t>, send_validation>(
        in_bytes,
        bytes_fragment,
        &bytes_validate_params);

      fragment->bytes.Set(
          bytes_fragment.is_null() ? nullptr : bytes_fragment.data());

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

      decltype(Traits::handles(input)) in_handles = Traits::handles(input);
      mojo::internal::MessageFragment<
          typename decltype(fragment->handles)::BaseType>
          handles_fragment(fragment.message());
      constexpr const mojo::internal::ContainerValidateParams& handles_validate_params =
          mojo::internal::GetArrayValidator<0, false, nullptr>();
      
      mojo::internal::Serialize<mojo::ArrayDataView<::mojo::native::SerializedHandleDataView>, send_validation>(
        in_handles,
        handles_fragment,
        &handles_validate_params);

      fragment->handles.Set(
          handles_fragment.is_null() ? nullptr : handles_fragment.data());
  }
};

}  // namespace mojo::internal

#endif  // IPC_IPC_MOJOM_SEND_VALIDATION_H_