pub struct FilterState { /* private fields */ }Expand description
A query and the candidates that match it, best first.
Candidates are strings to search; a match is a candidate’s index and the
character positions that matched, for highlight. With an empty query
every candidate matches, in order, except those hidden
(set_hidden): a collapsed tree node’s children
stay out of the list until something is typed.
Implementations§
Source§impl FilterState
impl FilterState
Sourcepub fn new<I, S>(candidates: I) -> FilterState
pub fn new<I, S>(candidates: I) -> FilterState
Filter candidates, with nothing typed yet.
Sourcepub fn set_candidates<I, S>(&mut self, candidates: I)
pub fn set_candidates<I, S>(&mut self, candidates: I)
Replace the candidates and filter them again.
pub fn candidates(&self) -> &[String]
Leave these candidates out while the query is empty (true hides).
Takes effect on the next refilter.
Sourcepub fn set_tree(&mut self, parents: Option<Vec<Option<usize>>>)
pub fn set_tree(&mut self, parents: Option<Vec<Option<usize>>>)
Filter as a tree (#428): parents[i] is candidate i’s parent,
and candidates come in tree order, each parent before its children.
While a query is typed, what matches keeps its ancestors, so a match
shows where it is: the list is the matches and their ancestors in
tree order, the ancestors marked as context with
nothing highlighted, and best is where the best match
is. None goes back to a flat ranking. Takes effect on the next
refilter.
Sourcepub fn set_highlight_limits(&mut self, limits: Vec<usize>)
pub fn set_highlight_limits(&mut self, limits: Vec<usize>)
Highlight at most the first limits[i] characters of candidate i:
for a candidate searched with more than its label (a description),
so only the label highlights. Takes effect on the next
refilter.
pub fn is_filtering(&self) -> bool
Sourcepub fn is_context(&self, position: usize) -> bool
pub fn is_context(&self, position: usize) -> bool
Whether the match at position is only there as an ancestor of a
match (set_tree): drawn dim, not picked first.
Sourcepub fn best(&self) -> Option<usize>
pub fn best(&self) -> Option<usize>
The position of the best match: the first, unless a tree keeps ancestors above it.
Sourcepub fn matches(&self) -> &[(usize, Vec<usize>)]
pub fn matches(&self) -> &[(usize, Vec<usize>)]
The matches, best first: candidate indices and the positions to highlight.
pub fn is_empty(&self) -> bool
Sourcepub fn index(&self, position: usize) -> Option<usize>
pub fn index(&self, position: usize) -> Option<usize>
The candidate at position in the matches.
Sourcepub fn position_of(&self, index: usize) -> Option<usize>
pub fn position_of(&self, index: usize) -> Option<usize>
Where candidate index is in the matches, if it matches.
Trait Implementations§
Source§impl Clone for FilterState
impl Clone for FilterState
Source§impl Debug for FilterState
impl Debug for FilterState
Source§impl Default for FilterState
impl Default for FilterState
impl Eq for FilterState
Source§impl PartialEq for FilterState
impl PartialEq for FilterState
impl StructuralPartialEq for FilterState
Auto Trait Implementations§
impl Freeze for FilterState
impl RefUnwindSafe for FilterState
impl Send for FilterState
impl Sync for FilterState
impl Unpin for FilterState
impl UnsafeUnpin for FilterState
impl UnwindSafe for FilterState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.