Trait oy::Methods[][src]

pub trait 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] { ... } }

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

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

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.

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

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.

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

Returns all interactive method names of this type.

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

Loading content...

Implementations on Foreign Types

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

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

impl<T: Methods + ?Sized> Methods for Box<T>[src]

impl<T: Methods + ?Sized> Methods for Rc<T>[src]

impl<T: Methods + ?Sized> Methods for Arc<T>[src]

Loading content...

Implementors

Loading content...