Trait Selector
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§
type Output
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§
fn select(&mut self, candidate: Candidate<'_>) -> Option<Self::Output>
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.
fn description(&self) -> String
fn description(&self) -> String
Returns a short description of the Selector
for debugging purposes.
Provided Methods§
fn find(self) -> Finder<One<Self>>where
Self: Sized,
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.
fn find_all(self) -> Finder<All<Self>>where
Self: Sized,
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
.