Skip to main content

Runtime

Trait Runtime 

Source
pub trait Runtime: Send + Sync {
    // Required methods
    fn lang(&self) -> &str;
    fn evaluate(
        &self,
        descriptor: &Descriptor,
        cell: &Cell,
        inputs: &mut dyn Inputs,
        budget: &mut Budget,
    ) -> Result<Scalar, EvalError>;
}
Expand description

The evaluator of one function language (code.lang of a descriptor).

evaluate computes the value of cell (a cell of the function descriptor describes; cell.fn_hash is the descriptor’s hash) from the cell’s arguments and from the values of other cells, which it reads through inputs. It must be a pure function of those: no clock, no randomness, no I/O. It charges its work to budget and propagates every error inputs and budget return (see EvalError).

It may be called more than once for one cell in one request: when it reads an input that is not available yet, read returns EvalError::Suspended, the engine evaluates the input, then calls evaluate again from the start (reads already made are then answered at once). So evaluate must not have side effects either.

Required Methods§

Source

fn lang(&self) -> &str

The language this runtime evaluates: a name (SPEC 2.2), e.g. expr. stored is the engine’s own (a lookup) and cannot be configured.

Source

fn evaluate( &self, descriptor: &Descriptor, cell: &Cell, inputs: &mut dyn Inputs, budget: &mut Budget, ) -> Result<Scalar, EvalError>

The value of cell, whose type must be the descriptor’s declared return type.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§