Skip to main content

Crate cel_core

Crate cel_core 

Source
Expand description

CEL-Core: High-level API for the Common Expression Language

This crate provides a unified Env for working with CEL expressions, following the cel-go architecture pattern.

§Quick Start

use cel_core::Env;
use cel_core::CelType;

// Create an environment with standard library and a variable
let env = Env::with_standard_library()
    .with_variable("x", CelType::Int);

// Parse and type-check in one step
let ast = env.compile("x + 1").unwrap();
assert!(ast.is_checked());

§Architecture

The Env struct coordinates:

  • Parser: Converts source text into an AST
  • Checker: Type-checks expressions and resolves references
  • Variables: User-defined variable declarations
  • Functions: Standard library + custom function declarations

§Modules

  • types: Core type system, AST, and declarations
  • parser: Lexer, parser, and macro expansion
  • checker: Type checking and overload resolution
  • ext: Extension libraries (strings, math, encoders, optionals)

§Proto Conversion

For proto wire format conversion (interop with cel-go, cel-cpp), use the cel-core-proto crate which provides CheckedExpr and ParsedExpr types.

Re-exports§

pub use parser::parse;
pub use parser::ParseError;
pub use parser::ParseResult;
pub use types::proto::proto_message_to_cel_type;
pub use types::proto::ResolvedProtoType;
pub use types::BinaryOp;
pub use types::CelType;
pub use types::CelValue;
pub use types::ComprehensionData;
pub use types::Expr;
pub use types::FunctionDecl;
pub use types::ListElement;
pub use types::MapEntry;
pub use types::OverloadDecl;
pub use types::Span;
pub use types::Spanned;
pub use types::SpannedExpr;
pub use types::StructField;
pub use types::UnaryOp;
pub use types::VariableDecl;

Modules§

ext
CEL extension libraries.
parser
CEL (Common Expression Language) parser.
time
Time parsing and formatting utilities for CEL timestamps and durations.
types
Common types for CEL: type system, values, AST, and declarations.

Structs§

Abbreviations
A validated set of abbreviations mapping short names to fully-qualified names.
Ast
Unified AST representation matching cel-go’s Ast type.
CheckError
A type checking error.
CheckResult
Result of type checking an expression.
Duration
A CEL duration value.
EmptyActivation
An empty activation with no bindings.
EnumValue
A CEL enum value with type information.
Env
Unified environment for CEL expression processing.
EvalError
An error that occurred during CEL evaluation.
HierarchicalActivation
A hierarchical activation that delegates to a parent if not found locally.
MapActivation
A simple activation backed by a HashMap.
Program
A compiled CEL program ready for evaluation.
ReferenceInfo
Reference information for a resolved identifier or function.
SharedActivation
An activation that wraps an Arc for shared ownership.
StructFieldValue
An evaluated struct field ready for message construction.
Timestamp
A CEL timestamp value.
TypeValue
A CEL type value (runtime representation of types).
ValueError
Error returned when converting from Value to a specific type fails.
ValueMap
A CEL map with heterogeneous keys.

Enums§

AbbrevError
Error when creating abbreviations.
AstError
Error type for Ast operations.
CheckErrorKind
The kind of type checking error.
CompileError
Error from compiling a CEL expression.
EvalErrorKind
The kind of evaluation error.
MapKey
A map key that supports CEL’s key types.
OptionalValue
A CEL optional value.
Value
A CEL runtime value.

Traits§

Activation
Trait for resolving variable bindings during evaluation.
MessageValue
A trait representing a protobuf message value at runtime.
ProtoRegistry
Trait for protobuf runtime operations (evaluator operations).
ProtoTypeResolver
Trait for protobuf descriptor pool access (checker operations).

Functions§

ast_to_string
Convert a CEL AST to source text.