| 79 | } |
| 80 | |
| 81 | absl::Status ConstantFromProto(const ConstantProto& proto, Constant& constant) { |
| 82 | switch (proto.constant_kind_case()) { |
| 83 | case ConstantProto::CONSTANT_KIND_NOT_SET: |
| 84 | constant = Constant{}; |
| 85 | break; |
| 86 | case ConstantProto::kNullValue: |
| 87 | constant.set_null_value(); |
| 88 | break; |
| 89 | case ConstantProto::kBoolValue: |
| 90 | constant.set_bool_value(proto.bool_value()); |
| 91 | break; |
| 92 | case ConstantProto::kInt64Value: |
| 93 | constant.set_int_value(proto.int64_value()); |
| 94 | break; |
| 95 | case ConstantProto::kUint64Value: |
| 96 | constant.set_uint_value(proto.uint64_value()); |
| 97 | break; |
| 98 | case ConstantProto::kDoubleValue: |
| 99 | constant.set_double_value(proto.double_value()); |
| 100 | break; |
| 101 | case ConstantProto::kStringValue: |
| 102 | constant.set_string_value(proto.string_value()); |
| 103 | break; |
| 104 | case ConstantProto::kBytesValue: |
| 105 | constant.set_bytes_value(proto.bytes_value()); |
| 106 | break; |
| 107 | case ConstantProto::kDurationValue: |
| 108 | constant.set_duration_value( |
| 109 | internal::DecodeDuration(proto.duration_value())); |
| 110 | break; |
| 111 | case ConstantProto::kTimestampValue: |
| 112 | constant.set_timestamp_value( |
| 113 | internal::DecodeTime(proto.timestamp_value())); |
| 114 | break; |
| 115 | default: |
| 116 | return absl::InvalidArgumentError( |
| 117 | absl::StrCat("unexpected ConstantKindCase: ", |
| 118 | static_cast<int>(proto.constant_kind_case()))); |
| 119 | } |
| 120 | return absl::OkStatus(); |
| 121 | } |
| 122 | |
| 123 | } // namespace cel::ast_internal |
no test coverage detected