// components/metrics/public/mojom/histogram_fetcher.mojom-shared.h is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2016 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_PUBLIC_MOJOM_HISTOGRAM_FETCHER_MOJOM_SHARED_H_
#define COMPONENTS_METRICS_PUBLIC_MOJOM_HISTOGRAM_FETCHER_MOJOM_SHARED_H_

#include <stdint.h>

#include <functional>
#include <iosfwd>
#include <type_traits>
#include <utility>

#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"

#include "components/metrics/public/mojom/histogram_fetcher.mojom-shared-internal.h"
#include "mojo/public/mojom/base/byte_string.mojom-shared.h"
#include "mojo/public/mojom/base/shared_memory.mojom-shared.h"
#include "mojo/public/cpp/bindings/lib/interface_serialization.h"
#include "mojo/public/cpp/system/data_pipe.h"



#include "components/metrics/public/mojom/histogram_fetcher.mojom-data-view.h"  // IWYU pragma: export




namespace std {

template <>
struct hash<::metrics::mojom::UmaChildPingStatus>
    : public mojo::internal::EnumHashImpl<::metrics::mojom::UmaChildPingStatus> {};

template <>
struct hash<::metrics::mojom::UmaPingCallSource>
    : public mojo::internal::EnumHashImpl<::metrics::mojom::UmaPingCallSource> {};

}  // namespace std

namespace mojo {


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::metrics::mojom::UmaChildPingStatus, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = EnumTraits<::metrics::mojom::UmaChildPingStatus, UserType>;

  static void Serialize(UserType input, int32_t* output) {
    *output = static_cast<int32_t>(Traits::ToMojom(input));
  }

  static bool Deserialize(int32_t input, UserType* output) {
    auto known_value = ::mojo::internal::ToKnownEnumValueHelper(
        static_cast<::metrics::mojom::UmaChildPingStatus>(input));
    if constexpr (requires {
                    {
                      Traits::FromMojom(known_value)
                    } -> std::same_as<UserType>;
                  }) {
      static_assert(std::same_as<::metrics::mojom::UmaChildPingStatus, UserType> ||
                        HasInfallibleConversion(::metrics::mojom::UmaChildPingStatus()),
                    "::metrics::mojom::UmaChildPingStatus does not have an infallible conversion, "
                    "use an optional return type.");
      *output = Traits::FromMojom(known_value);
      return true;
    } else {
      static_assert(
          requires {
            {
              Traits::FromMojom(known_value)
            } -> std::same_as<std::optional<UserType>>;
          }, "FromMojom must return by value or optional.");
      std::optional<UserType> from_mojom = Traits::FromMojom(known_value);
      if (from_mojom) {
        *output = *from_mojom;
      }
      return from_mojom.has_value();
    }
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::metrics::mojom::UmaPingCallSource, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = EnumTraits<::metrics::mojom::UmaPingCallSource, UserType>;

  static void Serialize(UserType input, int32_t* output) {
    *output = static_cast<int32_t>(Traits::ToMojom(input));
  }

  static bool Deserialize(int32_t input, UserType* output) {
    auto known_value = ::mojo::internal::ToKnownEnumValueHelper(
        static_cast<::metrics::mojom::UmaPingCallSource>(input));
    if constexpr (requires {
                    {
                      Traits::FromMojom(known_value)
                    } -> std::same_as<UserType>;
                  }) {
      static_assert(std::same_as<::metrics::mojom::UmaPingCallSource, UserType> ||
                        HasInfallibleConversion(::metrics::mojom::UmaPingCallSource()),
                    "::metrics::mojom::UmaPingCallSource does not have an infallible conversion, "
                    "use an optional return type.");
      *output = Traits::FromMojom(known_value);
      return true;
    } else {
      static_assert(
          requires {
            {
              Traits::FromMojom(known_value)
            } -> std::same_as<std::optional<UserType>>;
          }, "FromMojom must return by value or optional.");
      std::optional<UserType> from_mojom = Traits::FromMojom(known_value);
      if (from_mojom) {
        *output = *from_mojom;
      }
      return from_mojom.has_value();
    }
  }
};

}  // namespace internal

}  // namespace mojo


namespace metrics::mojom {


}  // metrics::mojom

// Declare TraceFormatTraits for enums, which should be defined in ::perfetto
// namespace.

namespace perfetto {

template <>
struct  TraceFormatTraits<::metrics::mojom::UmaChildPingStatus> {
 static void WriteIntoTrace(perfetto::TracedValue context, ::metrics::mojom::UmaChildPingStatus value);
};

} // namespace perfetto

namespace perfetto {

template <>
struct  TraceFormatTraits<::metrics::mojom::UmaPingCallSource> {
 static void WriteIntoTrace(perfetto::TracedValue context, ::metrics::mojom::UmaPingCallSource value);
};

} // namespace perfetto

#endif  // COMPONENTS_METRICS_PUBLIC_MOJOM_HISTOGRAM_FETCHER_MOJOM_SHARED_H_