Interactive

Trait Interactive 

Source
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§

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl AsDebug for &dyn Interactive

Source§

fn try_as_debug(&self) -> Result<'_, &dyn Debug>

Source§

impl AsDebug for &mut dyn Interactive

Source§

fn try_as_debug(&self) -> Result<'_, &dyn Debug>

Source§

impl AsMethods for &dyn Interactive

Source§

fn try_as_methods(&self) -> Result<'_, &dyn Methods>

Source§

impl AsMethods for &mut dyn Interactive

Source§

fn try_as_methods(&self) -> Result<'_, &dyn Methods>

Source§

impl AsMethodsMut for &mut dyn Interactive

Source§

fn try_as_methods_mut(&mut self) -> Result<'_, &mut dyn Methods>

Implementations on Foreign Types§

Source§

impl<'b, T: 'b + Interactive + ?Sized> Interactive for &'b T

Source§

fn get_field<'a>(&'a self, field_name: &'a str) -> Result<'a, &dyn Interactive>

Source§

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

Source§

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

Source§

impl<'b, T: 'b + Interactive + ?Sized> Interactive for &'b mut T

Source§

fn get_field<'a>(&'a self, field_name: &'a str) -> Result<'a, &dyn Interactive>

Source§

fn get_field_mut<'a>( &'a mut self, field_name: &'a str, ) -> Result<'a, &mut dyn Interactive>

Source§

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

Source§

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

Source§

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

Source§

fn get_field<'a>(&'a self, field_name: &'a str) -> Result<'a, &dyn Interactive>

Source§

fn get_field_mut<'a>( &'a mut self, field_name: &'a str, ) -> Result<'a, &mut dyn Interactive>

Source§

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

Source§

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

Source§

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

Source§

fn get_field<'a>(&'a self, field_name: &'a str) -> Result<'a, &dyn Interactive>

Source§

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

Source§

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

Source§

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

Source§

fn get_field<'a>(&'a self, field_name: &'a str) -> Result<'a, &dyn Interactive>

Source§

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

Source§

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

Implementors§