// components/metrics/private_metrics/mojom/private_metrics_interface.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 COMPONENTS_METRICS_PRIVATE_METRICS_MOJOM_PRIVATE_METRICS_INTERFACE_MOJOM_SEND_VALIDATION_H_
#define COMPONENTS_METRICS_PRIVATE_METRICS_MOJOM_PRIVATE_METRICS_INTERFACE_MOJOM_SEND_VALIDATION_H_

#include "components/metrics/private_metrics/mojom/private_metrics_interface.mojom-shared-internal.h"

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

      fragment->event_hash = Traits::event_hash(input);
      fragment->content_hash_$flag = Traits::content_hash(input).has_value();
      if (Traits::content_hash(input).has_value()) {
        fragment->content_hash_$value = Traits::content_hash(input).value();
      }

      decltype(Traits::studies_of_interest(input)) in_studies_of_interest = Traits::studies_of_interest(input);
      mojo::internal::MessageFragment<
          typename decltype(fragment->studies_of_interest)::BaseType>
          studies_of_interest_fragment(fragment.message());
      constexpr const mojo::internal::ContainerValidateParams& studies_of_interest_validate_params =
          mojo::internal::GetMapValidator<*&mojo::internal::GetArrayValidator<0, false, &mojo::internal::GetArrayValidator<0, false, nullptr>()>(), *&mojo::internal::GetArrayValidator<0, false, nullptr>()>();
      
      mojo::internal::Serialize<mojo::MapDataView<mojo::StringDataView, bool>, send_validation>(
        in_studies_of_interest,
        studies_of_interest_fragment,
        &studies_of_interest_validate_params);

      fragment->studies_of_interest.Set(
          studies_of_interest_fragment.is_null() ? nullptr : studies_of_interest_fragment.data());

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

      
      mojo::internal::Serialize<::metrics::private_metrics::mojom::PrivateMetricsEntry_Type>(
        Traits::type(input),
        &fragment->type);
  }
};

}  // namespace mojo::internal

#endif  // COMPONENTS_METRICS_PRIVATE_METRICS_MOJOM_PRIVATE_METRICS_INTERFACE_MOJOM_SEND_VALIDATION_H_