MCPcopy Create free account
hub / github.com/cel-rust/cel-rust / Opaque

Interface Opaque

cel/src/objects.rs:386–403  ·  view source on GitHub ↗

Trait for user-defined opaque values stored inside [`Value::Opaque`]. Implement this trait for types that should participate in CEL evaluation as opaque/user-defined values. An opaque value: - must report a stable runtime type name via [`Opaque::runtime_type_name`]; - participates in equality via the blanket [`OpaqueEq`] implementation; - can be formatted via [`AsDebug`]; - must be thread-safe (`

Source from the content-addressed store, hash-verified

384/// assert_eq!(a, b);
385/// ```
386pub trait Opaque: Any + OpaqueEq + AsDebug + Send + Sync {
387 /// Returns a stable, fully-qualified type name for this value's runtime type.
388 ///
389 /// This name is used to check type compatibility before attempting downcasts
390 /// during equality checks and other operations. It should be stable across
391 /// versions and unique within your application or library (e.g., a package
392 /// qualified name like `my.pkg.Type`).
393 fn runtime_type_name(&self) -> &str;
394
395 /// Optional JSON representation (requires the `json` feature).
396 ///
397 /// The default implementation returns `None`, indicating that the value
398 /// cannot be represented as JSON.
399 #[cfg(feature = "json")]
400 fn json(&self) -> Option<serde_json::Value> {
401 None
402 }
403}
404
405impl dyn Opaque {
406 pub fn downcast_ref<T: Any>(&self) -> Option<&T> {

Callers 8

optional_noneFunction · 0.85
optional_ofFunction · 0.85
try_fromMethod · 0.85
test_opaque_fnFunction · 0.85
opaque_eqFunction · 0.85
test_value_holder_dbgFunction · 0.85
test_jsonFunction · 0.85

Implementers 1

objects.rscel/src/objects.rs

Calls

no outgoing calls

Tested by

no test coverage detected