pub struct Evaluator<'a, C> { /* private fields */ }
Expand description

The virtual machine that runs commands

The virtual machine interprets strings and provides an output. It operates on the strings according to the specified mapping table, which can be manipulated via Evaluator::register and Evaluator::register_many.

Builting commands are autocomplete, which tries to look ahead by 1 query, and ? which lists all possible queries.

Implementations§

source§

impl<'a, C> Evaluator<'a, C>

source

pub fn new(context: C) -> Self

Create a new VM which owns a context. The context is used in handler functions and can be mutated.

source

pub fn set_recursion_limit(&mut self, limit: usize)

Set the recursion limit of nested calls.

source

pub fn context(&self) -> &C

Get a reference to this machine’s context.

source

pub fn context_mut(&mut self) -> &mut C

Get a mutable reference to this machine’s context.

source

pub fn register( &mut self, spec: Spec<'_, 'a, Type, String, C> ) -> Result<(), RegError>

Register a handler function for a command.

source

pub fn register_many( &mut self, spec: &[Spec<'_, 'a, Type, String, C>] ) -> Result<(), RegError>

Register an array of handler functions for a command, see Evaluator::register.

Trait Implementations§

source§

impl<'a, C> Evaluate<Result<String, String>> for Evaluator<'a, C>

source§

fn evaluate(&mut self, commands: &[Data<'_>]) -> Feedback

Evaluate a single statement Read more
source§

fn interpret_single(&mut self, statement: &str) -> Result<T, ParseError>

Set up the parser and call evaluate on the result Read more
source§

fn interpret_multiple(&mut self, code: &str) -> Result<T, ParseError>

Interpret several statements one-by-one Read more

Auto Trait Implementations§

§

impl<'a, C> RefUnwindSafe for Evaluator<'a, C>where C: RefUnwindSafe,

§

impl<'a, C> Send for Evaluator<'a, C>where C: Send,

§

impl<'a, C> Sync for Evaluator<'a, C>where C: Sync,

§

impl<'a, C> Unpin for Evaluator<'a, C>where C: Unpin,

§

impl<'a, C> UnwindSafe for Evaluator<'a, C>where C: UnwindSafe,

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.