pub trait Interactive:
AsDebug
+ AsMethods
+ AsMethodsMut {
// Provided methods
fn get_field<'a>(
&'a self,
field_name: &'a str,
) -> Result<'a, &dyn Interactive> { ... }
fn get_field_mut<'a>(
&'a mut self,
field_name: &'a str,
) -> Result<'a, &mut dyn Interactive> { ... }
fn eval_field(
&self,
field_name: &str,
f: &mut dyn FnMut(Result<'_, &dyn Debug>),
) { ... }
fn get_all_field_names(&self) -> &'static [&'static str] { ... }
}Expand description
A trait that gives interactive access to its fields as dyn Interactive or dyn Debug.
This trait gets implemented automatically when you derive it with Interactive.
See the macros documentation for more information.
Provided Methods§
Sourcefn get_field<'a>(&'a self, field_name: &'a str) -> Result<'a, &dyn Interactive>
fn get_field<'a>(&'a self, field_name: &'a str) -> Result<'a, &dyn Interactive>
Looks for a field with the given name and on success return a shared reference to it.
Sourcefn get_field_mut<'a>(
&'a mut self,
field_name: &'a str,
) -> Result<'a, &mut dyn Interactive>
fn get_field_mut<'a>( &'a mut self, field_name: &'a str, ) -> Result<'a, &mut dyn Interactive>
Looks for a field with the given name and on success return a mutable reference to it.
Sourcefn eval_field(
&self,
field_name: &str,
f: &mut dyn FnMut(Result<'_, &dyn Debug>),
)
fn eval_field( &self, field_name: &str, f: &mut dyn FnMut(Result<'_, &dyn Debug>), )
Looks for a field with the given name,
and passes it as a Ok(&dyn Debug) to the given closure.
On error the Err(InteractiveError) is passed to the closure instead.
Sourcefn get_all_field_names(&self) -> &'static [&'static str]
fn get_all_field_names(&self) -> &'static [&'static str]
Returns all interactive field names of this type.
Can be used to drive auto-completion in a CLI.