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;
76 virtual void BackUp(std::size_t size);
85void CallWrite(
Writer& writer,
const T& data) {
91T CallRead(
Reader& reader,
To<T> to) {
92 return Read(reader, to);
99 if constexpr (kIsWritable<T>) {
100 impl::CallWrite(*
this, data);
101 }
else if constexpr (std::is_aggregate_v<T>) {
104 "Serialization is not implemented for this type. You "
105 "either forgot to specialize IsDumpedAggregate for your type "
106 "(see <userver/dump/aggregates.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`."
114 "You either forgot to `#include <userver/dump/common_containers.hpp>`, "
115 "or you've got a non-standard data type and need to implement "
116 "`void Write(dump::Writer& writer, const T& data);` and put it "
117 "in the namespace of `T` or in `dump`."
125 if constexpr (kIsReadable<T>) {
126 return impl::CallRead(*
this,
To<T>{});
127 }
else if constexpr (std::is_aggregate_v<T>) {
130 "Serialization is not implemented for this type. You "
131 "either forgot to specialize IsDumpedAggregate for your type"
132 "(see <userver/dump/aggregates.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`."
140 "You either forgot to `#include <userver/dump/common_containers.hpp>`, "
141 "or you've got a non-standard data type and need to implement"
142 "`T Read(dump::Reader& reader, dump::To<T>);` and put it "
143 "in the namespace of `T` or in `dump`."