pub trait TypedValue {
// Required method
fn value_type() -> ValueType;
}
Expand description
Trait for types that have a known CEL type.
This trait provides type information for values that can be used in CEL expressions.
It is used in conjunction with IntoValue
and FromValue
to provide complete type
information for value conversions.
§Implementation
Important: This trait should generally not be implemented manually. For most use cases:
- Built-in types: Already have implementations (primitives, collections, etc.)
- Custom opaque types: Use the
#[derive(Opaque)]
macro which automatically implements this trait - Special cases: Only implement manually if you have very specific requirements
§Examples
§Using Built-in Types
use cel_cxx::{TypedValue, ValueType};
// Built-in types already implement TypedValue
assert_eq!(i64::value_type(), ValueType::Int);
assert_eq!(String::value_type(), ValueType::String);
assert_eq!(bool::value_type(), ValueType::Bool);
§Using Derive Macro for Custom Types
use cel_cxx::Opaque;
#[derive(Opaque, Debug, Clone, PartialEq)]
#[cel_cxx(display)]
struct CustomId(u64);
// TypedValue is automatically implemented by the derive macro
Required Methods§
Sourcefn value_type() -> ValueType
fn value_type() -> ValueType
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.