[][src]Trait endbasic_core::eval::Function

pub trait Function {
    pub fn metadata(&self) -> &CallableMetadata;
pub fn exec(&self, args: Vec<Value>) -> FunctionResult; }

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

pub fn metadata(&self) -> &CallableMetadata[src]

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.

pub fn exec(&self, args: Vec<Value>) -> FunctionResult[src]

Executes the function.

args contains the evaluated arguments as provided in the invocation of the function.

Loading content...

Implementors

Loading content...