Trait Function

Source
pub trait Function: Sync {
    // Required methods
    fn eval(&self, args: &str, f: &mut dyn FnMut(Result<'_, &dyn Debug>));
    fn function_name(&self) -> &'static str;
}
Expand description

A trait that allows to interactively evaluate a function and pass its result to the given closure.

This trait gets implemented automatically when you use the Function attribute. See its documentation for more information.

Required Methods§

Source

fn eval(&self, args: &str, f: &mut dyn FnMut(Result<'_, &dyn Debug>))

Parses the args string into the expected arguments of the method, executes the method and passes the result as a Ok(&dyn Debug) to the given closure.

On error an Err(InteractiveError) is passed to the closure instead.

Source

fn function_name(&self) -> &'static str

Returns the functions name.

Can be used to drive auto-completion in a CLI.

Trait Implementations§

Source§

impl Collect for &'static dyn Function

Implementors§