| 366 | } |
| 367 | |
| 368 | absl::optional<NetworkAddressRep> NetworkAddressRep::Unwrap( |
| 369 | const cel::Value& value) { |
| 370 | auto opaque = value.AsOpaque(); |
| 371 | if (!opaque.has_value() || |
| 372 | opaque->GetTypeId() != cel::TypeId<NetworkAddressRep>()) { |
| 373 | return absl::nullopt; |
| 374 | } |
| 375 | |
| 376 | // Note: safety depends on: |
| 377 | // 1) correctly implementing GetTypeId |
| 378 | // 2) the TypeId is unique |
| 379 | // 3) all calls to UnsafeOpaqueValue with the dispatcher provide the expected |
| 380 | // content type. |
| 381 | return opaque->content().To<NetworkAddressRep>(); |
| 382 | } |
| 383 | |
| 384 | absl::optional<NetworkAddressRep> NetworkAddressRep::Parse( |
| 385 | absl::string_view str) { |