#[non_exhaustive]pub struct Facet<'a> {
pub name: &'a str,
pub mode: Selecting,
pub values: &'a [FacetValue<'a>],
}Expand description
A named dimension a set can be narrowed by.
One word for six things that were six mechanisms. MNW’s discover page filters by free text, a flat any-of over item types, a tree of tags, a numeric range over price, a nested one-of over AI tier, and a browse position in the tag tree held separately from the tag selection — and the last two being separate is the whole reason a filter row there needs a tick box and a chevron. The panel is a mixed bag of hand-written controls because nothing named the thing they all are.
Deliberately wider than that one page. audiofiles’ library browser and goingson’s filters are the same shape, and a word that only fitted discover would be discover’s markup with a neutral name on it.
§What it does not say
What picking a value calls. This crate names no address, so a facet is
paired with routes the way a column’s sortable flag is
paired with what reordering calls.
How a tree is drawn. Indented rows, a column of panes, a breadcrumb and a
list: all four are honest renderings of the same described facet, and a
terminal will not pick the same one a browser does. FacetValue::depth is
what a renderer needs to draw any of them; the choice is not described.
Which values to show. A tag tree has thousands of nodes and a panel shows a handful. Deciding which handful is the app’s — it is the same question as which rows go in a table, and no table member answers it either.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: &'a strWhat the dimension is called, as the user reads it.
mode: SelectingHow many of its values may be in force, and in what shape.
values: &'a [FacetValue<'a>]The values on offer, in the order they are drawn.
A Selecting::Text facet has none: the value is whatever was typed,
and a description that listed the possible strings would be listing the
corpus. A Selecting::Range facet has none either, for the reason
FieldKind::Range takes bounds rather than options — the ends are the
question and the values between them are not enumerable.
Implementations§
Source§impl<'a> Facet<'a>
impl<'a> Facet<'a>
Sourcepub const fn new(
name: &'a str,
mode: Selecting,
values: &'a [FacetValue<'a>],
) -> Self
pub const fn new( name: &'a str, mode: Selecting, values: &'a [FacetValue<'a>], ) -> Self
A dimension with values to pick from.
Sourcepub fn engaged(&self) -> bool
pub fn engaged(&self) -> bool
Whether the facet is narrowing the set right now.
The question a renderer asks to decide whether to offer a way out of it,
and the reason it is derived rather than carried: a facet with nothing
standing is unengaged by construction, so a member saying so could
disagree with the values beside it. Standing::Inherited does not
count — something further up is what is doing the narrowing, and clearing
a child that was never picked clears nothing.
Always false for Selecting::Text and Selecting::Range, which
carry no values. A host that wants a clear affordance on those knows
whether its own box is empty; the description does not hold the typed
string.
Sourcepub fn reach(&self) -> u8
pub fn reach(&self) -> u8
The deepest value in the facet, or zero when it is flat.
What an indenting renderer needs to reserve a gutter before it draws the first row, which is “First paint is final paint” applied to a tree: a gutter widened as deeper values arrive is the reflow that rule forbids.