cel/interpreter
Types
Functions
pub fn default_context() -> Context
Create a [context.Context
] with the default functions.
The default functions are:
- filter: Filters out each element that doesn’t meet the predicate provided. Example:
[1,2,3].filter(x, x % 2 == 0)
will result in[2]
. - map: Maps each element with the provided function. Example:
[1,2,3].map(x, x * 2)
will result in[2,4,6]
. - all: Checks whether the provided predicate is true for all of the elements. Example:
[1,2,3].all(x, x > 1)
will result infalse
. - size: Returns the amount of elements of the container argument provided. Example:
size([1,2,3])
will result in3
. - has: Checks whether an identifier has been set in the execution context. Example:
has(doesnt.exist)
will result infalse
for an empty context. - exists: Similar to
all
but will be true if at least one predicate returns true. Example:[1,2,3].exists(x, x > 1)
will result intrue
. - exists_one: Similar to
exists
. Will return true if exactly one of the predicates is true. Example:[1,2,3].exists_one(x, x > 1)
will result infalse
.
pub fn execute(
program: Program,
ctx: Context,
) -> Result(Value, ExecutionError)
Execute a CEL program