pub trait Command {
    fn metadata(&self) -> &CallableMetadata;
    fn exec<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        span: &'life1 BuiltinCallSpan,
        machine: &'life2 mut Machine
    ) -> Pin<Box<dyn Future<Output = CommandResult> + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait
; }
Expand description

A trait to define a command that is executed by a Machine.

The commands themselves are immutable but they can reference mutable state. Given that EndBASIC is not threaded, it is sufficient for those references to be behind a RefCell and/or an Rc.

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§

Returns the metadata for this command.

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.

Executes the command.

span contains the details about the command invocation. machine provides mutable access to the current state of the machine invoking the command.

Commands cannot return any value except for errors.

Implementors§