Trait IntoValue

Source
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§

Source

fn into_value(self) -> Value

Converts this value into a CEL Value.

This method performs the conversion from a Rust type to its corresponding CEL value representation. The conversion should be lossless where possible.

§Returns

A Value that represents this Rust value in the CEL type system.

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.

Implementations on Foreign Types§

Source§

impl IntoValue for &str

Source§

impl IntoValue for &[u8]

Source§

impl IntoValue for bool

Source§

impl IntoValue for f32

Source§

impl IntoValue for f64

Source§

impl IntoValue for i16

Source§

impl IntoValue for i32

Source§

impl IntoValue for i64

Source§

impl IntoValue for isize

Source§

impl IntoValue for u16

Source§

impl IntoValue for u32

Source§

impl IntoValue for u64

Source§

impl IntoValue for ()

Source§

impl IntoValue for usize

Source§

impl IntoValue for Box<str>

Source§

impl IntoValue for Box<[u8]>

Source§

impl IntoValue for String

Source§

impl IntoValue for Vec<u8>

Source§

impl IntoValue for SystemTime

Source§

impl<K: IntoMapKey + Clone, V: IntoValue + Clone> IntoValue for &[(K, V)]

Source§

impl<K: IntoMapKey, V: IntoValue> IntoValue for BTreeMap<K, V>

Source§

impl<K: IntoMapKey, V: IntoValue> IntoValue for LinkedList<(K, V)>

Source§

impl<K: IntoMapKey, V: IntoValue> IntoValue for VecDeque<(K, V)>

Source§

impl<K: IntoMapKey, V: IntoValue> IntoValue for Vec<(K, V)>

Source§

impl<K: IntoMapKey, V: IntoValue> IntoValue for HashMap<K, V>

Source§

impl<T: IntoValue + Clone> IntoValue for &[T]

Source§

impl<T: IntoValue + Clone> IntoValue for &T

Source§

impl<T: IntoValue + Clone> IntoValue for &mut T

Source§

impl<T: IntoValue> IntoValue for Option<T>

Source§

impl<T: IntoValue> IntoValue for LinkedList<T>

Source§

impl<T: IntoValue> IntoValue for VecDeque<T>

Source§

impl<T: IntoValue> IntoValue for Vec<T>

Implementors§