| 33 | using ConstantProto = cel::expr::Constant; |
| 34 | |
| 35 | absl::Status ConstantToProto(const Constant& constant, |
| 36 | ConstantProto* absl_nonnull proto) { |
| 37 | return absl::visit(absl::Overload( |
| 38 | [proto](absl::monostate) -> absl::Status { |
| 39 | proto->clear_constant_kind(); |
| 40 | return absl::OkStatus(); |
| 41 | }, |
| 42 | [proto](std::nullptr_t) -> absl::Status { |
| 43 | proto->set_null_value(google::protobuf::NULL_VALUE); |
| 44 | return absl::OkStatus(); |
| 45 | }, |
| 46 | [proto](bool value) -> absl::Status { |
| 47 | proto->set_bool_value(value); |
| 48 | return absl::OkStatus(); |
| 49 | }, |
| 50 | [proto](int64_t value) -> absl::Status { |
| 51 | proto->set_int64_value(value); |
| 52 | return absl::OkStatus(); |
| 53 | }, |
| 54 | [proto](uint64_t value) -> absl::Status { |
| 55 | proto->set_uint64_value(value); |
| 56 | return absl::OkStatus(); |
| 57 | }, |
| 58 | [proto](double value) -> absl::Status { |
| 59 | proto->set_double_value(value); |
| 60 | return absl::OkStatus(); |
| 61 | }, |
| 62 | [proto](const BytesConstant& value) -> absl::Status { |
| 63 | proto->set_bytes_value(value); |
| 64 | return absl::OkStatus(); |
| 65 | }, |
| 66 | [proto](const StringConstant& value) -> absl::Status { |
| 67 | proto->set_string_value(value); |
| 68 | return absl::OkStatus(); |
| 69 | }, |
| 70 | [proto](absl::Duration value) -> absl::Status { |
| 71 | return internal::EncodeDuration( |
| 72 | value, proto->mutable_duration_value()); |
| 73 | }, |
| 74 | [proto](absl::Time value) -> absl::Status { |
| 75 | return internal::EncodeTime( |
| 76 | value, proto->mutable_timestamp_value()); |
| 77 | }), |
| 78 | constant.kind()); |
| 79 | } |
| 80 | |
| 81 | absl::Status ConstantFromProto(const ConstantProto& proto, Constant& constant) { |
| 82 | switch (proto.constant_kind_case()) { |
no test coverage detected