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] { ... }
}
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§
sourcefn eval_method(
&self,
method_name: &str,
args: &str,
f: &mut dyn FnMut(Result<'_, &dyn Debug>)
)
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.
sourcefn eval_method_mut(
&mut 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>)
)
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.
sourcefn get_all_method_names(&self) -> &'static [&'static str]
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.