Trait endbasic_core::syms::Function
source · pub trait Function {
fn metadata(&self) -> &CallableMetadata;
fn exec<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 FunctionCallSpan,
symbols: &'life2 mut Symbols
) -> Pin<Box<dyn Future<Output = FunctionResult> + 'async_trait>>
where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
A trait to define a function that is executed by a Machine.
The functions themselves are, for now, pure. They can only access their input arguments and cannot modify the state of the machine.
Idiomatically, these objects need to provide a new() method that returns an Rc<Callable>, as
that’s the type used throughout the execution engine.
Required Methods§
sourcefn metadata(&self) -> &CallableMetadata
fn metadata(&self) -> &CallableMetadata
Returns the metadata for this function.
The return value takes the form of a reference to force the callable to store the metadata as a struct field so that calls to this function are guaranteed to be cheap.
sourcefn exec<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 FunctionCallSpan,
symbols: &'life2 mut Symbols
) -> Pin<Box<dyn Future<Output = FunctionResult> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn exec<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 FunctionCallSpan,
symbols: &'life2 mut Symbols
) -> Pin<Box<dyn Future<Output = FunctionResult> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Executes the function.
span contains the details about the function call. The arguments within the span are
unevaluated as provided in the invocation of the function. These are needed to support
functions that need unevaluated symbol references (such as LBOUND(array)). Because most
functions don’t support this kind of input, they should use eval::eval_all to process all
arguments.
symbols provides mutable access to the current state of the machine’s symbols.