pub trait IntoValue: Sized {
// Required method
fn into_value(self) -> Value;
}
Expand description
Trait for converting values into CEL values.
This trait enables automatic conversion from Rust types to CEL Value
instances.
It is typically used alongside TypedValue
to provide complete value conversion
functionality.
§Implementation
Important: This trait should generally not be implemented manually. For most use cases:
- Built-in types: Already have implementations
- Custom opaque types: Use the
#[derive(Opaque)]
macro - Collection types: Automatically implemented for compatible element types
§Examples
§Using Built-in Conversions
use cel_cxx::{IntoValue, Value};
// Built-in types can be converted directly
let string_val = "hello".into_value();
let int_val = 42i64.into_value();
let bool_val = true.into_value();
assert_eq!(string_val, Value::String("hello".to_string().into()));
assert_eq!(int_val, Value::Int(42));
assert_eq!(bool_val, Value::Bool(true));
§Collection Conversions
use cel_cxx::{IntoValue, Value};
let list = vec![1i64, 2i64, 3i64].into_value();
let map = std::collections::HashMap::from([
("key".to_string(), "value".to_string())
]).into_value();
Required Methods§
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.