chromium/mojo/public/tools/bindings/generators/cpp_templates/enum_serialization_declaration.tmpl

{%- set mojom_type = enum|get_qualified_name_for_kind(
        flatten_nested_kind=True) %}

namespace internal {

template <typename MaybeConstUserType>
struct Serializer<{{mojom_type}}, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = EnumTraits<{{mojom_type}}, 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) {
    return Traits::FromMojom(::mojo::internal::ToKnownEnumValueHelper(
        static_cast<{{mojom_type}}>(input)), output);
  }
};

}  // namespace internal