1#include <userver/proto-structs/io/userver/proto_structs/time_of_day.hpp>
3#include <google/type/timeofday.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 {
11TimeOfDay ReadProtoStruct(ReadContext& ctx, To<TimeOfDay>,
const ::google::type::TimeOfDay& msg)
try {
12 return TimeOfDay(
utils::impl::InternalTag{}, msg.hours(), msg.minutes(), msg.seconds(), msg.nanos());
13}
catch (
const ValueError& e) {
14 ctx.AddError(e.what());
18void WriteProtoStruct(WriteContext&,
const TimeOfDay& obj, ::google::type::TimeOfDay& msg) {
19 msg.set_hours(
static_cast<std::int32_t>(obj.Hours().count()));
20 msg.set_minutes(
static_cast<std::int32_t>(obj.Minutes().count()));
21 msg.set_seconds(
static_cast<std::int32_t>(obj.Seconds().count()));
22 msg.set_nanos(
static_cast<std::int32_t>(obj.Nanos().count()));