// components/private_ai/mojom/oak_session.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_PRIVATE_AI_MOJOM_OAK_SESSION_MOJOM_SEND_VALIDATION_H_
#define COMPONENTS_PRIVATE_AI_MOJOM_OAK_SESSION_MOJOM_SEND_VALIDATION_H_

#include "components/private_ai/mojom/oak_session.mojom-shared-internal.h"
#include "sandbox/policy/mojom/sandbox.mojom-shared.h"

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

      decltype(Traits::ephemeral_public_key(input)) in_ephemeral_public_key = Traits::ephemeral_public_key(input);
      mojo::internal::MessageFragment<
          typename decltype(fragment->ephemeral_public_key)::BaseType>
          ephemeral_public_key_fragment(fragment.message());
      constexpr const mojo::internal::ContainerValidateParams& ephemeral_public_key_validate_params =
          mojo::internal::GetArrayValidator<65, false, nullptr>();
      
      mojo::internal::Serialize<mojo::ArrayDataView<uint8_t>, send_validation>(
        in_ephemeral_public_key,
        ephemeral_public_key_fragment,
        &ephemeral_public_key_validate_params);

      fragment->ephemeral_public_key.Set(
          ephemeral_public_key_fragment.is_null() ? nullptr : ephemeral_public_key_fragment.data());

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

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

      fragment->ciphertext.Set(
          ciphertext_fragment.is_null() ? nullptr : ciphertext_fragment.data());

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

}  // namespace mojo::internal

#endif  // COMPONENTS_PRIVATE_AI_MOJOM_OAK_SESSION_MOJOM_SEND_VALIDATION_H_