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`."
106 "You either forgot to `#include <userver/dump/common_containers.hpp>`, "
107 "or you've got a non-standard data type and need to implement "
108 "`void Write(dump::Writer& writer, const T& data);` and put it "
109 "in the namespace of `T` or in `dump`."
117 if constexpr (kIsReadable<T>) {
118 return impl::CallRead(*
this,
To<T>{});
119 }
else if constexpr (std::is_aggregate_v<T>) {
122 "Serialization is not implemented for this type. You "
123 "either forgot to specialize IsDumpedAggregate for your type"
124 "(see <userver/dump/aggregates.hpp>) "
125 "or you've got a non-standard data type and need to implement "
126 "`T Read(dump::Reader& reader, dump::To<T>);` and put it "
127 "in the namespace of `T` or in `dump`."
132 "You either forgot to `#include <userver/dump/common_containers.hpp>`, "
133 "or you've got a non-standard data type and need to implement"
134 "`T Read(dump::Reader& reader, dump::To<T>);` and put it "
135 "in the namespace of `T` or in `dump`."