]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Add fmt::format specialisation
authorVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 31 Jul 2023 10:27:28 +0000 (11:27 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 31 Jul 2023 10:27:28 +0000 (11:27 +0100)
src/client/rspamc.cxx

index bf7a23c474b350cae8ac6379351162422792a35b..e934efeb181d5837b911d6e65333be738ff3646c 100644 (file)
@@ -1,11 +1,11 @@
-/*-
+/*
  * Copyright 2023 Vsevolod Stakhov
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -354,6 +354,14 @@ static constexpr auto emphasis_argument(const T &arg, int precision) -> auto
        return fmt::format("{:.{}f}", arg, precision);
 }
 
+template<>
+struct fmt::formatter<rspamd_action_type> : fmt::formatter<string_view> {
+       auto format(rspamd_action_type c, format_context &ctx) const
+       {
+               return formatter<string_view>::format(std::string_view{rspamd_action_to_str(c)}, ctx);
+       }
+};
+
 using sort_lambda = std::function<int(const ucl_object_t *, const ucl_object_t *)>;
 static const auto sort_map = frozen::make_unordered_map<frozen::string, sort_lambda>({
        {"name", [](const ucl_object_t *o1, const ucl_object_t *o2) -> int {