pub enum Value {
}
Expand description
Main CEL value type.
Value
is the core value type of the CEL expression system, supporting all data types
defined by the CEL specification. Each variant corresponds to a CEL basic type or composite type.
§CEL Type Mapping
Null
→ CEL nullBool
→ CEL boolInt
→ CEL int (64-bit signed integer)Uint
→ CEL uint (64-bit unsigned integer)Double
→ CEL double (64-bit floating point)String
→ CEL stringBytes
→ CEL bytesDuration
→ CEL duration (Protocol Buffers Duration)Timestamp
→ CEL timestamp (Protocol Buffers Timestamp)List
→ CEL listMap
→ CEL mapType
→ CEL type (type value)Error
→ CEL errorOpaque
→ Opaque custom typesOptional
→ Optional value type
§Examples
use cel_cxx::Value;
// Basic types
let null_val = Value::Null;
let bool_val = Value::Bool(true);
let int_val = Value::Int(-42);
let uint_val = Value::Uint(42u64);
let double_val = Value::Double(3.14);
let string_val = Value::String("hello".to_string().into());
let bytes_val = Value::Bytes(vec![1, 2, 3].into());
// Time types
let duration = Value::Duration(chrono::Duration::seconds(30));
let timestamp = Value::Timestamp(chrono::Utc::now());
// Container types
let list = Value::List(vec![Value::Int(1), Value::Int(2)]);
Variants§
Null
Null value
Bool(bool)
Boolean value
Int(i64)
Signed 64-bit integer
Uint(u64)
Unsigned 64-bit integer
Double(f64)
64-bit floating point number
String(ArcStr)
UTF-8 string
Bytes(ArcBytes)
Byte array
Struct(())
Struct (not yet implemented)
Duration(Duration)
Duration (Protocol Buffers Duration)
Timestamp(Timestamp)
Timestamp (Protocol Buffers Timestamp)
List(ListValue)
List of values
Map(MapValue)
Key-value map
Unknown(())
Unknown type (not yet implemented)
Type(ValueType)
CEL type value
Error(Error)
Error value
Opaque(OpaqueValue)
Opaque custom type
Optional(OptionalValue)
Optional value type
Implementations§
Source§impl Value
impl Value
Sourcepub fn value_type(&self) -> ValueType
pub fn value_type(&self) -> ValueType
Returns the concrete type of this value.
Returns detailed ValueType
information including generic parameters.
For container types (List, Map), infers element or key-value types.
§Type Inference Rules
- List: Returns specific
List<T>
if all elements have the same type; otherwiseList<dyn>
- Map: Infers key and value types; uses
dyn
types if inconsistent - Optional: Infers type from contained value; uses
Optional<dyn>
for empty values
§Examples
use cel_cxx::{Value, ValueType, ListType};
let val = Value::String("hello".to_string().into());
assert_eq!(val.value_type(), ValueType::String);
// Homogeneous list
let list = Value::List(vec![Value::Int(1), Value::Int(2)]);
assert_eq!(list.value_type(), ValueType::List(ListType::new(ValueType::Int)));
// Heterogeneous list
let mixed_list = Value::List(vec![Value::Int(1), Value::String("hello".to_string().into())]);
assert_eq!(mixed_list.value_type(), ValueType::List(ListType::new(ValueType::Dyn)));
Trait Implementations§
Source§impl From<Box<dyn Opaque>> for Value
impl From<Box<dyn Opaque>> for Value
Source§fn from(value: OpaqueValue) -> Self
fn from(value: OpaqueValue) -> Self
Converts to this type from the input type.
Source§impl<K: IntoMapKey, V: IntoValue> From<LinkedList<(K, V)>> for Value
impl<K: IntoMapKey, V: IntoValue> From<LinkedList<(K, V)>> for Value
Source§fn from(value: LinkedList<(K, V)>) -> Self
fn from(value: LinkedList<(K, V)>) -> Self
Converts to this type from the input type.
Source§impl<T: IntoValue> From<LinkedList<T>> for Value
impl<T: IntoValue> From<LinkedList<T>> for Value
Source§fn from(value: LinkedList<T>) -> Self
fn from(value: LinkedList<T>) -> Self
Converts to this type from the input type.
Source§impl From<SystemTime> for Value
impl From<SystemTime> for Value
Source§fn from(value: SystemTime) -> Self
fn from(value: SystemTime) -> Self
Converts to this type from the input type.
Source§impl<'a, K, V> TryFrom<&'a Value> for BTreeMap<K, V>where
K: TryFrom<&'a MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<&'a Value, Error = FromValueError> + TypedValue,
impl<'a, K, V> TryFrom<&'a Value> for BTreeMap<K, V>where
K: TryFrom<&'a MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<&'a Value, Error = FromValueError> + TypedValue,
Source§impl<'a, K, V> TryFrom<&'a Value> for HashMap<K, V>where
K: TryFrom<&'a MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<&'a Value, Error = FromValueError> + TypedValue,
impl<'a, K, V> TryFrom<&'a Value> for HashMap<K, V>where
K: TryFrom<&'a MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<&'a Value, Error = FromValueError> + TypedValue,
Source§impl<'a, K, V> TryFrom<&'a Value> for LinkedList<(K, V)>where
K: TryFrom<&'a MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<&'a Value, Error = FromValueError> + TypedValue,
impl<'a, K, V> TryFrom<&'a Value> for LinkedList<(K, V)>where
K: TryFrom<&'a MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<&'a Value, Error = FromValueError> + TypedValue,
Source§impl<'a, T: TryFrom<&'a Value, Error = FromValueError> + TypedValue> TryFrom<&'a Value> for LinkedList<T>
impl<'a, T: TryFrom<&'a Value, Error = FromValueError> + TypedValue> TryFrom<&'a Value> for LinkedList<T>
Source§impl<'a, T: TryFrom<&'a Value, Error = FromValueError> + TypedValue> TryFrom<&'a Value> for Option<T>
impl<'a, T: TryFrom<&'a Value, Error = FromValueError> + TypedValue> TryFrom<&'a Value> for Option<T>
Source§impl<'a, T: TryFrom<&'a Value, Error = FromValueError> + TypedValue> TryFrom<&'a Value> for Optional<T>
impl<'a, T: TryFrom<&'a Value, Error = FromValueError> + TypedValue> TryFrom<&'a Value> for Optional<T>
Source§impl TryFrom<&Value> for SystemTime
impl TryFrom<&Value> for SystemTime
Source§impl<'a, K, V> TryFrom<&'a Value> for Vec<(K, V)>where
K: TryFrom<&'a MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<&'a Value, Error = FromValueError> + TypedValue,
impl<'a, K, V> TryFrom<&'a Value> for Vec<(K, V)>where
K: TryFrom<&'a MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<&'a Value, Error = FromValueError> + TypedValue,
Source§impl<'a, T: TryFrom<&'a Value, Error = FromValueError> + TypedValue> TryFrom<&'a Value> for Vec<T>
impl<'a, T: TryFrom<&'a Value, Error = FromValueError> + TypedValue> TryFrom<&'a Value> for Vec<T>
Source§impl<'a, K, V> TryFrom<&'a Value> for VecDeque<(K, V)>where
K: TryFrom<&'a MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<&'a Value, Error = FromValueError> + TypedValue,
impl<'a, K, V> TryFrom<&'a Value> for VecDeque<(K, V)>where
K: TryFrom<&'a MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<&'a Value, Error = FromValueError> + TypedValue,
Source§impl<'a, T: TryFrom<&'a Value, Error = FromValueError> + TypedValue> TryFrom<&'a Value> for VecDeque<T>
impl<'a, T: TryFrom<&'a Value, Error = FromValueError> + TypedValue> TryFrom<&'a Value> for VecDeque<T>
Source§impl<K, V> TryFrom<Value> for BTreeMap<K, V>where
K: TryFrom<MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<Value, Error = FromValueError> + TypedValue,
impl<K, V> TryFrom<Value> for BTreeMap<K, V>where
K: TryFrom<MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<Value, Error = FromValueError> + TypedValue,
Source§impl<K, V> TryFrom<Value> for HashMap<K, V>where
K: TryFrom<MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<Value, Error = FromValueError> + TypedValue,
impl<K, V> TryFrom<Value> for HashMap<K, V>where
K: TryFrom<MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<Value, Error = FromValueError> + TypedValue,
Source§impl<K, V> TryFrom<Value> for LinkedList<(K, V)>where
K: TryFrom<MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<Value, Error = FromValueError> + TypedValue,
impl<K, V> TryFrom<Value> for LinkedList<(K, V)>where
K: TryFrom<MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<Value, Error = FromValueError> + TypedValue,
Source§impl<T: TypedValue + TryFrom<Value, Error = FromValueError>> TryFrom<Value> for LinkedList<T>
impl<T: TypedValue + TryFrom<Value, Error = FromValueError>> TryFrom<Value> for LinkedList<T>
Source§impl<T: TryFrom<Value, Error = FromValueError> + TypedValue> TryFrom<Value> for Option<T>
impl<T: TryFrom<Value, Error = FromValueError> + TypedValue> TryFrom<Value> for Option<T>
Source§impl<T: TryFrom<Value, Error = FromValueError> + TypedValue> TryFrom<Value> for Optional<T>
impl<T: TryFrom<Value, Error = FromValueError> + TypedValue> TryFrom<Value> for Optional<T>
Source§impl TryFrom<Value> for SystemTime
impl TryFrom<Value> for SystemTime
Source§impl<K, V> TryFrom<Value> for Vec<(K, V)>where
K: TryFrom<MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<Value, Error = FromValueError> + TypedValue,
impl<K, V> TryFrom<Value> for Vec<(K, V)>where
K: TryFrom<MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<Value, Error = FromValueError> + TypedValue,
Source§impl<T: TypedValue + TryFrom<Value, Error = FromValueError>> TryFrom<Value> for Vec<T>
impl<T: TypedValue + TryFrom<Value, Error = FromValueError>> TryFrom<Value> for Vec<T>
Source§impl<K, V> TryFrom<Value> for VecDeque<(K, V)>where
K: TryFrom<MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<Value, Error = FromValueError> + TypedValue,
impl<K, V> TryFrom<Value> for VecDeque<(K, V)>where
K: TryFrom<MapKey, Error = FromMapKeyError> + TypedMapKey + Eq + Hash + Ord,
V: TryFrom<Value, Error = FromValueError> + TypedValue,
Source§impl<T: TypedValue + TryFrom<Value, Error = FromValueError>> TryFrom<Value> for VecDeque<T>
impl<T: TypedValue + TryFrom<Value, Error = FromValueError>> TryFrom<Value> for VecDeque<T>
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl !RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl !UnwindSafe for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more