Skip to main content

Selector

Trait Selector 

Source
pub trait Selector {
    type Output;

    // Required methods
    fn select(&mut self, candidate: Candidate<'_>) -> Option<Self::Output>;
    fn description(&self) -> String;

    // Provided methods
    fn find(self) -> Finder<One<Self>>
       where Self: Sized { ... }
    fn find_all(self) -> Finder<All<Self>>
       where Self: Sized { ... }
}
Expand description

A type that traverses the widget tree to “select” data and produce some output.

Required Associated Types§

Source

type Output

The output type of the Selector.

For most selectors, this will normally be a Target. However, some selectors may want to return a more limited type to encode the selection guarantees in the type system.

For instance, the implementations of String and str of Selector return a target::Text instead of a generic Target, since they are guaranteed to only select text.

Required Methods§

Source

fn select(&mut self, candidate: Candidate<'_>) -> Option<Self::Output>

Performs a selection of the given Candidate, if applicable.

This method traverses the widget tree in depth-first order.

Source

fn description(&self) -> String

Returns a short description of the Selector for debugging purposes.

Provided Methods§

Source

fn find(self) -> Finder<One<Self>>
where Self: Sized,

Returns a widget::Operation that runs the Selector and stops after the first Output is produced.

Source

fn find_all(self) -> Finder<All<Self>>
where Self: Sized,

Returns a widget::Operation that runs the Selector for the entire widget tree and aggregates all of its Output.

Implementations on Foreign Types§

Source§

impl Selector for &str

Source§

type Output = Text

Source§

fn select( &mut self, candidate: Candidate<'_>, ) -> Option<<&str as Selector>::Output>

Source§

fn description(&self) -> String

Source§

impl Selector for String

Source§

type Output = Text

Source§

fn select( &mut self, candidate: Candidate<'_>, ) -> Option<<String as Selector>::Output>

Source§

fn description(&self) -> String

Source§

impl Selector for Point

Source§

type Output = Target

Source§

fn select( &mut self, candidate: Candidate<'_>, ) -> Option<<Point as Selector>::Output>

Source§

fn description(&self) -> String

Source§

impl Selector for Id

Source§

type Output = Target

Source§

fn select( &mut self, candidate: Candidate<'_>, ) -> Option<<Id as Selector>::Output>

Source§

fn description(&self) -> String

Implementors§

Source§

impl<F, T> Selector for F
where F: FnMut(Candidate<'_>) -> Option<T>,