Trait cursive_core::view::Finder

source ·
pub trait Finder {
    // Required method
    fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
       where V: View,
             F: FnMut(&mut V);

    // Provided methods
    fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
       where V: View,
             F: FnOnce(&mut V) -> R { ... }
    fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
       where V: View,
             F: FnOnce(&mut V) -> R { ... }
    fn find_name<V>(&mut self, name: &str) -> Option<ViewRef<V>>
       where V: View { ... }
}
Expand description

Provides call_on<V: View> to views.

This trait is mostly a wrapper around View::call_on_any.

It provides a nicer interface to find a view when you know its type.

Required Methods§

source

fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
where V: View, F: FnMut(&mut V),

Runs a callback on all views identified by sel.

Useful if you have multiple views of the same type with the same name.

Provided Methods§

source

fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
where V: View, F: FnOnce(&mut V) -> R,

Runs a callback on the view identified by sel.

If the view is found, return the result of callback.

If the view is not found, or if it is not of the asked type, it returns None.

source

fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
where V: View, F: FnOnce(&mut V) -> R,

Convenient method to use call_on with a view::Selector::Name.

source

fn find_name<V>(&mut self, name: &str) -> Option<ViewRef<V>>
where V: View,

Convenient method to find a view wrapped in an NamedView.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T: View> Finder for T