// mojo/public/mojom/base/proto_wrapper.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 MOJO_PUBLIC_MOJOM_BASE_PROTO_WRAPPER_MOJOM_SEND_VALIDATION_H_
#define MOJO_PUBLIC_MOJOM_BASE_PROTO_WRAPPER_MOJOM_SEND_VALIDATION_H_

#include "mojo/public/mojom/base/proto_wrapper.mojom-shared-internal.h"
#include "mojo/public/mojom/base/big_buffer.mojom-shared.h"

#include "mojo/public/mojom/base/proto_wrapper.mojom-data-view.h"

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

namespace mojo::internal {

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

      decltype(Traits::proto_name(input)) in_proto_name = Traits::proto_name(input);
      mojo::internal::MessageFragment<
          typename decltype(fragment->proto_name)::BaseType> proto_name_fragment(
              fragment.message());
      
      mojo::internal::Serialize<mojo::StringDataView, send_validation>(
        in_proto_name,
        proto_name_fragment);

      fragment->proto_name.Set(
          proto_name_fragment.is_null() ? nullptr : proto_name_fragment.data());

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

      decltype(Traits::smuggled(input)) in_smuggled = Traits::smuggled(input);
      mojo::internal::MessageFragment<decltype(fragment->smuggled)>
          smuggled_fragment(fragment.message());
      smuggled_fragment.Claim(&fragment->smuggled);
      
      mojo::internal::Serialize<::mojo_base::mojom::BigBufferDataView, send_validation>(
        in_smuggled,
        smuggled_fragment,
        true);

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

}  // namespace mojo::internal

#endif  // MOJO_PUBLIC_MOJOM_BASE_PROTO_WRAPPER_MOJOM_SEND_VALIDATION_H_