cel_core/lib.rs
1//! CEL-Core: High-level API for the Common Expression Language
2//!
3//! This crate provides a unified `Env` for working with CEL expressions,
4//! following the cel-go architecture pattern.
5//!
6//! # Quick Start
7//!
8//! ```
9//! use cel_core::Env;
10//! use cel_core::CelType;
11//!
12//! // Create an environment with standard library and a variable
13//! let env = Env::with_standard_library()
14//! .with_variable("x", CelType::Int);
15//!
16//! // Parse and type-check in one step
17//! let ast = env.compile("x + 1").unwrap();
18//! assert!(ast.is_checked());
19//! ```
20//!
21//! # Architecture
22//!
23//! The `Env` struct coordinates:
24//! - **Parser**: Converts source text into an AST
25//! - **Checker**: Type-checks expressions and resolves references
26//! - **Variables**: User-defined variable declarations
27//! - **Functions**: Standard library + custom function declarations
28//!
29//! # Modules
30//!
31//! - `types`: Core type system, AST, and declarations
32//! - `parser`: Lexer, parser, and macro expansion
33//! - `checker`: Type checking and overload resolution
34//! - `ext`: Extension libraries (strings, math, encoders, optionals)
35//!
36//! # Proto Conversion
37//!
38//! For proto wire format conversion (interop with cel-go, cel-cpp), use the
39//! `cel-core-proto` crate which provides `CheckedExpr` and `ParsedExpr` types.
40
41mod ast;
42mod env;
43pub mod unparser;
44
45// Core modules
46pub mod checker;
47pub mod ext;
48pub mod parser;
49pub mod types;
50
51pub use ast::{Ast, AstError};
52pub use env::{CompileError, Env};
53pub use unparser::ast_to_string;
54
55// Re-export from checker module
56pub use checker::{
57 check, CheckError, CheckErrorKind, CheckResult, ReferenceInfo, STANDARD_LIBRARY,
58};
59
60// Re-export from parser module
61pub use parser::{parse, ParseError, ParseOptions, ParseResult};
62
63// Re-export from types module
64pub use types::{
65 BinaryOp, CelType, CelValue, Expr, FunctionDecl, ListElement, MapEntry, OverloadDecl, Span,
66 Spanned, SpannedExpr, StructField, UnaryOp, VariableDecl,
67};