Struct cel_interpreter::FunctionCtx
source · pub struct FunctionCtx<'t, 'c, 'e> {
pub name: Rc<String>,
pub target: Option<&'t CelType>,
pub ptx: &'c Context<'c>,
pub args: &'e [Expression],
}Expand description
FunctionCtx is a context object passed to functions when they are called.
It contains references ot the target object (if the function is called as
a method), the program context (Context) which gives functions access
to variables, and the arguments to the function call.
Fields§
§name: Rc<String>§target: Option<&'t CelType>§ptx: &'c Context<'c>§args: &'e [Expression]Implementations§
source§impl<'t, 'c, 'e> FunctionCtx<'t, 'c, 'e>
impl<'t, 'c, 'e> FunctionCtx<'t, 'c, 'e>
sourcepub fn target(&self) -> Result<&'t CelType, ExecutionError>
pub fn target(&self) -> Result<&'t CelType, ExecutionError>
Returns a reference to the target object if the function is being called as a method, or it returns an error if the function is not being called as a method.
sourcepub fn check_no_method(&self) -> Result<(), ExecutionError>
pub fn check_no_method(&self) -> Result<(), ExecutionError>
Checks that the function is not being called as a method, and returns an error if it is.
sourcepub fn resolve(&self, expr: &'e Expression) -> Result<CelType, ExecutionError>
pub fn resolve(&self, expr: &'e Expression) -> Result<CelType, ExecutionError>
Resolves the given expression using the program’s Context.
sourcepub fn resolve_all(&self, exprs: &[Expression]) -> ResolveResult
pub fn resolve_all(&self, exprs: &[Expression]) -> ResolveResult
Resolves all of the given expressions using the program’s Context.
The resolved values are returned as a CelType::List.
sourcepub fn resolve_arg(&self, index: usize) -> Result<CelType, ExecutionError>
pub fn resolve_arg(&self, index: usize) -> Result<CelType, ExecutionError>
Resolves the argument at the given index. An error is returned if the argument does not exist.
sourcepub fn arg(&self, index: usize) -> Result<&'e Expression, ExecutionError>
pub fn arg(&self, index: usize) -> Result<&'e Expression, ExecutionError>
Returns the argument at the given index. An error is returned if the argument does not exist.