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>

source

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.

source

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.

source

pub fn resolve(&self, expr: &'e Expression) -> Result<CelType, ExecutionError>

Resolves the given expression using the program’s Context.

source

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.

source

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.

source

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.

source

pub fn arg_ident(&self, index: usize) -> Result<Rc<String>, ExecutionError>

Returns the argument at the given index as a identifier. An error is returned if the argument does not exist, or if it is not an identifier.

source

pub fn error(&self, message: &str) -> Result<CelType, ExecutionError>

Returns an execution error for the currently execution function.

Auto Trait Implementations§

§

impl<'t, 'c, 'e> !RefUnwindSafe for FunctionCtx<'t, 'c, 'e>

§

impl<'t, 'c, 'e> !Send for FunctionCtx<'t, 'c, 'e>

§

impl<'t, 'c, 'e> !Sync for FunctionCtx<'t, 'c, 'e>

§

impl<'t, 'c, 'e> Unpin for FunctionCtx<'t, 'c, 'e>

§

impl<'t, 'c, 'e> !UnwindSafe for FunctionCtx<'t, 'c, 'e>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.