Enum Constant

Source
pub enum Constant {
    Null,
    Bool(bool),
    Int(i64),
    Uint(u64),
    Double(f64),
    Bytes(BytesValue),
    String(StringValue),
    Duration(Duration),
    Timestamp(DateTime<Utc>),
}
Expand description

CEL constant value.

Constant represents constant values known at compile time, supporting CEL’s basic data types. Constants can be used for compile-time optimization and type inference.

§Supported Types

  • Null: Null value
  • Bool: Boolean value
  • Int: 64-bit signed integer
  • Uint: 64-bit unsigned integer
  • Double: 64-bit floating point number
  • String: UTF-8 string
  • Bytes: Byte array
  • Duration: Time duration
  • Timestamp: Timestamp

§Examples

use cel_cxx::Constant;

let null_const = Constant::Null;
let bool_const = Constant::Bool(true);
let int_const = Constant::Int(42);
let string_const = Constant::String("hello".to_string().into());

Variants§

§

Null

Null constant

§

Bool(bool)

Boolean constant

§

Int(i64)

Signed integer constant

§

Uint(u64)

Unsigned integer constant

§

Double(f64)

Floating point constant

§

Bytes(BytesValue)

Byte array constant

§

String(StringValue)

String constant

§

Duration(Duration)

Duration constant

§

Timestamp(DateTime<Utc>)

Timestamp constant

Implementations§

Source§

impl Constant

Source

pub fn value_type(&self) -> ValueType

Returns the type of the constant.

Returns the CEL type corresponding to the constant value.

Source

pub fn value(&self) -> Value

Converts the constant to a CEL value.

Converts the constant to the corresponding Value type.

Trait Implementations§

Source§

impl Clone for Constant

Source§

fn clone(&self) -> Constant

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Constant

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Constant

Source§

fn default() -> Constant

Returns the “default value” for a type. Read more
Source§

impl From<&[u8]> for Constant

Source§

fn from(value: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Constant

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<()> for Constant

Source§

fn from(value: ()) -> Self

Converts to this type from the input type.
Source§

impl From<ArcSlice<[u8]>> for Constant

Source§

fn from(value: BytesValue) -> Self

Converts to this type from the input type.
Source§

impl From<ArcSlice<str>> for Constant

Source§

fn from(value: StringValue) -> Self

Converts to this type from the input type.
Source§

impl From<Box<[u8]>> for Constant

Source§

fn from(value: Box<[u8]>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<str>> for Constant

Source§

fn from(value: Box<str>) -> Self

Converts to this type from the input type.
Source§

impl From<DateTime<Utc>> for Constant

Source§

fn from(value: Timestamp) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Constant

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<SystemTime> for Constant

Source§

fn from(value: SystemTime) -> Self

Converts to this type from the input type.
Source§

impl From<TimeDelta> for Constant

Source§

fn from(value: Duration) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for Constant

Source§

fn from(value: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Constant

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Constant

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Constant

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Constant

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Constant

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Constant

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for Constant

Source§

fn from(value: isize) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Constant

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Constant

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Constant

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Constant

Source§

fn from(value: usize) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Constant

Source§

fn eq(&self, other: &Constant) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Value> for Constant

Source§

type Error = FromValueError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for Constant

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more