cel_std/lib.rs
1//! CEL standard library: `min`, `max`, `clamp`, and related numeric functions built on Rust's
2//! standard library, registered via [`cel_parser::OpLookup::register_operation`].
3//!
4//! # Examples
5//!
6//! ```rust
7//! use cel_parser::OpLookup;
8//!
9//! let mut lookup = OpLookup::new();
10//! cel_std::install(&mut lookup);
11//! ```
12
13mod math;
14
15/// Registers every CEL standard-library function on `lookup`: `min`, `max`, `clamp`, `abs`,
16/// `signum`, `sqrt`, `floor`, `ceil`, `trunc`, `fract`, and `round_ties_even`.
17///
18/// These functions use persistent named registrations, so they are always reachable,
19/// including inside closure bodies. Library functions are never isolated; only
20/// transient, per-declaration scopes (pushed via [`cel_parser::OpLookup::push_scope`])
21/// are isolated during nested body compilation.
22///
23/// # Panics
24/// Panics if a standard numeric signature is already installed. Install once per lookup;
25/// independent libraries may add disjoint overloads before or after installation.
26///
27/// - Complexity: O(s²) in the number of installed operation signatures.
28///
29/// # Examples
30/// ```
31/// let mut lookup = cel_parser::OpLookup::new();
32/// cel_std::install(&mut lookup);
33/// assert_eq!(lookup.operation_signatures("min").count(), 14);
34/// ```
35pub fn install(lookup: &mut cel_parser::OpLookup) {
36 math::install(lookup).expect("CEL standard-library signatures must be installed once");
37}