Trait Methods

Source
pub trait Methods {
    // Provided methods
    fn eval_method(
        &self,
        method_name: &str,
        args: &str,
        f: &mut dyn FnMut(Result<'_, &dyn Debug>),
    ) { ... }
    fn eval_method_mut(
        &mut self,
        method_name: &str,
        args: &str,
        f: &mut dyn FnMut(Result<'_, &dyn Debug>),
    ) { ... }
    fn get_all_method_names(&self) -> &'static [&'static str] { ... }
}
Expand description

A trait that allows to interactively evaluate a structs methods and pass their result to the given closure.

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

Provided Methods§

Source

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

Looks for a method with the given name, 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 the Err(InteractiveError) is passed to the closure instead.

This method does not have access to methods that take &mut self as their receiver, use eval_method_mut instead.

Source

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

Looks for a method with the given name, 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 the Err(InteractiveError) is passed to the closure instead.

Source

fn get_all_method_names(&self) -> &'static [&'static str]

Returns all interactive method names of this type.

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

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + Methods + ?Sized> Methods for &'a T

Source§

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

Source§

fn get_all_method_names(&self) -> &'static [&'static str]

Source§

impl<'a, T: 'a + Methods + ?Sized> Methods for &'a mut T

Source§

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

Source§

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

Source§

fn get_all_method_names(&self) -> &'static [&'static str]

Source§

impl<T: Methods + ?Sized> Methods for Box<T>

Source§

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

Source§

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

Source§

fn get_all_method_names(&self) -> &'static [&'static str]

Source§

impl<T: Methods + ?Sized> Methods for Rc<T>

Source§

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

Source§

fn get_all_method_names(&self) -> &'static [&'static str]

Source§

impl<T: Methods + ?Sized> Methods for Arc<T>

Source§

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

Source§

fn get_all_method_names(&self) -> &'static [&'static str]

Implementors§