1#include <userver/proto-structs/io/userver/proto_structs/duration.hpp>
3#include <google/protobuf/duration.pb.h>
5#include <userver/proto-structs/exceptions.hpp>
6#include <userver/proto-structs/io/context.hpp>
7#include <userver/utils/impl/internal_tag.hpp>
9namespace proto_structs::io {
11Duration ReadProtoStruct(ReadContext& ctx, To<Duration>,
const ::google::protobuf::Duration& msg)
try
13 return Duration(utils::impl::InternalTag{}, msg.seconds(), msg.nanos());
14}
catch (
const ValueError& e) {
15 ctx.AddError(e.what());
19void WriteProtoStruct(WriteContext&,
const Duration& obj, ::google::protobuf::Duration& msg) {
20 msg.set_seconds(obj.Seconds().count());
21 msg.set_nanos(
static_cast<std::int32_t>(obj.Nanos().count()));