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 declarationsparser: Lexer, parser, and macro expansionchecker: Type checking and overload resolutionext: 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.
- Check
Error - A type checking error.
- Check
Result - Result of type checking an expression.
- Duration
- A CEL duration value.
- Empty
Activation - An empty activation with no bindings.
- Enum
Value - A CEL enum value with type information.
- Env
- Unified environment for CEL expression processing.
- Eval
Error - An error that occurred during CEL evaluation.
- Hierarchical
Activation - 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.
- Reference
Info - Reference information for a resolved identifier or function.
- Shared
Activation - An activation that wraps an Arc for shared ownership.
- Struct
Field Value - An evaluated struct field ready for message construction.
- Timestamp
- A CEL timestamp value.
- Type
Value - A CEL type value (runtime representation of types).
- Value
Error - Error returned when converting from Value to a specific type fails.
- Value
Map - A CEL map with heterogeneous keys.
Enums§
- Abbrev
Error - Error when creating abbreviations.
- AstError
- Error type for Ast operations.
- Check
Error Kind - The kind of type checking error.
- Compile
Error - Error from compiling a CEL expression.
- Eval
Error Kind - The kind of evaluation error.
- MapKey
- A map key that supports CEL’s key types.
- Optional
Value - A CEL optional value.
- Value
- A CEL runtime value.
Traits§
- Activation
- Trait for resolving variable bindings during evaluation.
- Message
Value - A trait representing a protobuf message value at runtime.
- Proto
Registry - Trait for protobuf runtime operations (evaluator operations).
- Proto
Type Resolver - Trait for protobuf descriptor pool access (checker operations).
Functions§
- ast_
to_ string - Convert a CEL AST to source text.