[][src]Trait molt::types::Command

pub trait Command {
    fn execute(&self, interp: &mut Interp, argv: &[Value]) -> MoltResult;
}

A trait defining a Molt command object: a struct that implements a command (and may also have context data).

A simple command should be defined as a CommandFunc; define a full-fledged Command struct when the command needs access to context data other than that provided by the the interpreter itself. For example, application-specific commands will often need access to application data, which can be provided as attributes of the Command struct.

TODO: Revise this so that argv: &[Value].

Required methods

fn execute(&self, interp: &mut Interp, argv: &[Value]) -> MoltResult

The Command's execution method: the Molt interpreter calls this method to execute the command. The method receives the object itself, the interpreter, and an array representing the command and its arguments.

Loading content...

Implementors

Loading content...