8#include <userver/dump/fwd.hpp>
9#include <userver/dump/meta.hpp>
11USERVER_NAMESPACE_BEGIN
17class Error
final :
public std::runtime_error {
19 explicit Error(std::string message) : std::runtime_error(message) {}
25 virtual ~Writer() =
default;
31 void Write(
const T& data);
42 virtual void WriteRaw(std::string_view data) = 0;
50 virtual ~Reader() =
default;
77void CallWrite(
Writer& writer,
const T& data) {
83T CallRead(
Reader& reader, To<T> to) {
84 return Read(reader, to);
91 if constexpr (kIsWritable<T>) {
92 impl::CallWrite(*
this, data);
93 }
else if constexpr (std::is_aggregate_v<T>) {
96 "Serialization is not implemented for this type. You "
97 "either forgot to specialize IsDumpedAggregate for your type "
98 "(see <userver/dump/aggregates.hpp>)"
99 "or you've got a non-standard data type and need to implement "
100 "`void Write(dump::Writer& writer, const T& data);` and put it "
101 "in the namespace of `T` or in `dump`.");
105 "You either forgot to `#include <userver/dump/common_containers.hpp>`, "
106 "or you've got a non-standard data type and need to implement "
107 "`void Write(dump::Writer& writer, const T& data);` and put it "
108 "in the namespace of `T` or in `dump`.");
115 if constexpr (kIsReadable<T>) {
116 return impl::CallRead(*
this, To<T>{});
117 }
else if constexpr (std::is_aggregate_v<T>) {
120 "Serialization is not implemented for this type. You "
121 "either forgot to specialize IsDumpedAggregate for your type"
122 "(see <userver/dump/aggregates.hpp>) "
123 "or you've got a non-standard data type and need to implement "
124 "`T Read(dump::Reader& reader, dump::To<T>);` and put it "
125 "in the namespace of `T` or in `dump`.");
129 "You either forgot to `#include <userver/dump/common_containers.hpp>`, "
130 "or you've got a non-standard data type and need to implement"
131 "`T Read(dump::Reader& reader, dump::To<T>);` and put it "
132 "in the namespace of `T` or in `dump`.");