Skip to content

Commit c3876e6

Browse files
committed
kafka/metadata_response: Add custom formatter specialization
And remove `operator<<` Signed-off-by: Oren Leiman <[email protected]>
1 parent 9be4a5d commit c3876e6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/v/kafka/protocol/metadata.h

+15-5
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,21 @@ struct metadata_response {
6969
void decode(iobuf buf, api_version version) {
7070
data.decode(std::move(buf), version);
7171
}
72-
73-
friend std::ostream&
74-
operator<<(std::ostream& os, const metadata_response& r) {
75-
return os << r.data;
76-
}
7772
};
7873

7974
} // namespace kafka
75+
76+
template<>
77+
struct fmt::formatter<kafka::metadata_response> {
78+
template<typename ParseContext>
79+
constexpr auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
80+
return ctx.begin();
81+
}
82+
83+
template<typename FormatContext>
84+
auto format(
85+
[[maybe_unused]] const kafka::metadata_response& v,
86+
FormatContext& ctx) const -> decltype(ctx.out()) {
87+
return fmt::format_to(ctx.out(), "{}", v.data);
88+
}
89+
};

0 commit comments

Comments
 (0)